Skip to content

Commit fd4f7a4

Browse files
committed
add oppo feature
1 parent 70ce4b6 commit fd4f7a4

File tree

9 files changed

+248
-0
lines changed

9 files changed

+248
-0
lines changed

client/mixpush-oppo/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

client/mixpush-oppo/build.gradle

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
apply plugin: 'com.android.library'
2+
3+
android {
4+
compileSdkVersion 34
5+
6+
defaultConfig {
7+
minSdkVersion 19
8+
}
9+
10+
repositories {
11+
flatDir {
12+
dirs 'libs'
13+
}
14+
}
15+
sourceSets {
16+
main {
17+
jniLibs.srcDirs = ['libs']
18+
}
19+
}
20+
buildTypes {
21+
release {
22+
minifyEnabled false
23+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
24+
}
25+
}
26+
27+
}
28+
29+
dependencies {
30+
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
31+
implementation project(path: ':mixpush-core')
32+
implementation 'commons-codec:commons-codec:1.6'
33+
}
34+
apply from: '../../maven_public.gradle'
138 KB
Binary file not shown.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
package="com.heytap.mcssdk">
3+
4+
<uses-permission android:name="com.coloros.mcs.permission.RECIEVE_MCS_MESSAGE" />
5+
<uses-permission android:name="com.heytap.mcs.permission.RECIEVE_MCS_MESSAGE" />
6+
7+
<application>
8+
<service
9+
android:name="com.heytap.msp.push.service.CompatibleDataMessageCallbackService"
10+
android:exported="false"
11+
android:permission="com.coloros.mcs.permission.SEND_MCS_MESSAGE">
12+
<intent-filter>
13+
<action android:name="com.coloros.mcs.action.RECEIVE_MCS_MESSAGE" />
14+
</intent-filter>
15+
</service> <!--兼容Q以下版本-->
16+
17+
<service
18+
android:name="com.heytap.msp.push.service.DataMessageCallbackService"
19+
android:exported="false"
20+
android:permission="com.heytap.mcs.permission.SEND_PUSH_MESSAGE">
21+
22+
<intent-filter>
23+
<action android:name="com.heytap.mcs.action.RECEIVE_MCS_MESSAGE" />
24+
<action android:name="com.heytap.msp.push.RECEIVE_MCS_MESSAGE" />
25+
</intent-filter>
26+
</service> <!--兼容Q版本-->
27+
28+
<meta-data
29+
android:name="OPPO_APP_SECRET"
30+
android:value="UNIFIEDPUSH-${OPPO_APP_SECRET}" />
31+
<meta-data
32+
android:name="OPPO_APP_KEY"
33+
android:value="UNIFIEDPUSH-${OPPO_APP_KEY}" />
34+
35+
<activity
36+
android:name="com.mixpush.oppo.OppoMessageReceiveActivity"
37+
android:exported="true"
38+
android:theme="@android:style/Theme.Translucent.NoTitleBar">
39+
<intent-filter>
40+
<data
41+
android:host="com.mixpush.oppo"
42+
android:path="/message"
43+
android:scheme="mixpush" />
44+
45+
<action android:name="android.intent.action.VIEW" />
46+
<action android:name="com.mixpush.oppo.message" />
47+
48+
<category android:name="android.intent.category.DEFAULT" />
49+
<category android:name="android.intent.category.BROWSABLE" />
50+
</intent-filter>
51+
</activity>
52+
</application>
53+
54+
</manifest>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package com.mixpush.oppo;
2+
3+
import android.app.Activity;
4+
import android.net.Uri;
5+
import android.os.Bundle;
6+
7+
import com.mixpush.core.MixPushClient;
8+
import com.mixpush.core.MixPushMessage;
9+
10+
public class OppoMessageReceiveActivity extends Activity {
11+
@Override
12+
protected void onCreate(Bundle savedInstanceState) {
13+
super.onCreate(savedInstanceState);
14+
Uri data = getIntent().getData();
15+
this.finish();
16+
if (data != null) {
17+
MixPushMessage message = new MixPushMessage();
18+
message.setPlatform(OppoPushProvider.OPPO);
19+
message.setTitle(data.getQueryParameter("title"));
20+
message.setDescription(data.getQueryParameter("description"));
21+
message.setPayload(data.getQueryParameter("payload"));
22+
MixPushClient.getInstance().getHandler().getLogger().log(OppoPushProvider.TAG, "url is " + data.toString());
23+
MixPushClient.getInstance().getHandler().getPushReceiver().onNotificationMessageClicked(this.getApplicationContext(), message);
24+
} else {
25+
MixPushClient.getInstance().openApp(this);
26+
}
27+
}
28+
}
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
package com.mixpush.oppo;
2+
3+
import android.content.Context;
4+
import android.os.Build;
5+
6+
import com.heytap.msp.push.HeytapPushManager;
7+
import com.heytap.msp.push.callback.ICallBackResultService;
8+
import com.mixpush.core.BaseMixPushProvider;
9+
import com.mixpush.core.MixPushClient;
10+
import com.mixpush.core.MixPushHandler;
11+
import com.mixpush.core.MixPushPlatform;
12+
import com.mixpush.core.RegisterType;
13+
14+
public class OppoPushProvider extends BaseMixPushProvider {
15+
public static final String OPPO = "oppo";
16+
public static final String TAG = OPPO;
17+
18+
19+
@Override
20+
public void register(Context context, RegisterType type) {
21+
String appSecret = getMetaData(context, "OPPO_APP_SECRET");
22+
String appKey = getMetaData(context, "OPPO_APP_KEY");
23+
HeytapPushManager.init(context, MixPushClient.debug);
24+
HeytapPushManager.register(context, appKey, appSecret, new MyCallBackResultService(context.getApplicationContext()));
25+
String registerID = HeytapPushManager.getRegisterID();
26+
if (registerID != null) {
27+
MixPushPlatform mixPushPlatform = new MixPushPlatform(OppoPushProvider.OPPO, registerID);
28+
MixPushClient.getInstance().getHandler().getPushReceiver().onRegisterSucceed(context, mixPushPlatform);
29+
}
30+
}
31+
32+
@Override
33+
public void unRegister(Context context) {
34+
35+
}
36+
37+
@Override
38+
public String getRegisterId(final Context context) {
39+
return HeytapPushManager.getRegisterID();
40+
}
41+
42+
@Override
43+
public boolean isSupport(Context context) {
44+
if (Build.VERSION.SDK_INT < 19) {
45+
return false;
46+
}
47+
String brand = Build.BRAND.toLowerCase();
48+
String manufacturer = Build.MANUFACTURER.toLowerCase();
49+
if (manufacturer.equals("oneplus") || manufacturer.equals("oppo") || brand.equals("oppo") || brand.equals("realme")) {
50+
HeytapPushManager.init(context, true);
51+
return HeytapPushManager.isSupportPush(context);
52+
}
53+
return false;
54+
}
55+
56+
@Override
57+
public String getPlatformName() {
58+
return OppoPushProvider.OPPO;
59+
}
60+
}
61+
62+
class MyCallBackResultService implements ICallBackResultService {
63+
Context context;
64+
MixPushHandler handler = MixPushClient.getInstance().getHandler();
65+
66+
67+
public MyCallBackResultService(Context context) {
68+
this.context = context;
69+
}
70+
71+
@Override
72+
public void onRegister(int responseCode, String registerID) {
73+
handler.getLogger().log(OppoPushProvider.TAG, "onRegister responseCode = " + responseCode + ", registerID = " + registerID);
74+
MixPushPlatform mixPushPlatform = new MixPushPlatform(OppoPushProvider.OPPO, registerID);
75+
handler.getPushReceiver().onRegisterSucceed(context, mixPushPlatform);
76+
}
77+
78+
@Override
79+
public void onUnRegister(int responseCode) {
80+
81+
}
82+
83+
@Override
84+
public void onSetPushTime(int responseCode, String pushTime) {
85+
86+
}
87+
88+
@Override
89+
public void onGetPushStatus(int responseCode, int status) {
90+
handler.getLogger().log(OppoPushProvider.TAG, "onGetPushStatus responseCode = " + responseCode + ", status = " + status);
91+
}
92+
93+
@Override
94+
public void onGetNotificationStatus(int responseCode, int status) {
95+
handler.getLogger().log(OppoPushProvider.TAG, "onGetNotificationStatus responseCode = " + responseCode + ", status = " + status);
96+
}
97+
98+
@Override
99+
public void onError(int i, String s) {
100+
101+
}
102+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
<string name="system_default_channel">系统默认通道</string>
4+
</resources>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
<string name="system_default_channel">system default channel</string>
4+
</resources>

0 commit comments

Comments
 (0)