Update Android SDK to v3.1.1 & Update MyReceiver to JPushReceiver

This commit is contained in:
Hevin 2018-01-27 09:41:35 +08:00
parent 261eb44473
commit 1954d6b55b
4 changed files with 11 additions and 25 deletions

View File

@ -161,25 +161,14 @@
<!-- User defined. For test only 用户自定义的广播接收器 --> <!-- User defined. For test only 用户自定义的广播接收器 -->
<receiver <receiver
android:name="cn.jiguang.cordova.push.MyReceiver" android:name="cn.jiguang.cordova.push.JPushReceiver"
android:enabled="true"> android:enabled="true">
<intent-filter android:priority="1000">
<action android:name="cn.jpush.android.intent.NOTIFICATION_RECEIVED_PROXY" />
<!-- Required 显示通知栏 -->
<category android:name="$PACKAGE_NAME" />
</intent-filter>
<intent-filter> <intent-filter>
<action android:name="cn.jpush.android.intent.REGISTRATION" /> <action android:name="cn.jpush.android.intent.REGISTRATION" />
<!-- Required 用户注册SDK的intent -->
<action android:name="cn.jpush.android.intent.UNREGISTRATION" />
<action android:name="cn.jpush.android.intent.MESSAGE_RECEIVED" /> <action android:name="cn.jpush.android.intent.MESSAGE_RECEIVED" />
<!-- Required 用户接收SDK消息的intent -->
<action android:name="cn.jpush.android.intent.NOTIFICATION_RECEIVED" /> <action android:name="cn.jpush.android.intent.NOTIFICATION_RECEIVED" />
<!-- Required 用户接收SDK通知栏信息的intent -->
<action android:name="cn.jpush.android.intent.NOTIFICATION_OPENED" /> <action android:name="cn.jpush.android.intent.NOTIFICATION_OPENED" />
<!-- Required 用户打开自定义通知栏的intent --> <action android:name="cn.jpush.android.intent.CONNECTION" />
<action android:name="cn.jpush.android.intent.ACTION_RICHPUSH_CALLBACK" />
<!-- Optional 用户接受Rich Push Javascript 回调函数的intent -->
<category android:name="$PACKAGE_NAME" /> <category android:name="$PACKAGE_NAME" />
</intent-filter> </intent-filter>
</receiver> </receiver>
@ -198,7 +187,7 @@
<receiver android:name="cn.jiguang.cordova.push.JPushEventReceiver"> <receiver android:name="cn.jiguang.cordova.push.JPushEventReceiver">
<intent-filter> <intent-filter>
<action android:name="cn.jpush.android.intent.RECEIVE_MESSAGE" /> <action android:name="cn.jpush.android.intent.RECEIVE_MESSAGE" />
<category android:name="$PACKAGE_NAME"></category> <category android:name="$PACKAGE_NAME" />
</intent-filter> </intent-filter>
</receiver> </receiver>
@ -207,9 +196,9 @@
<meta-data android:name="JPUSH_APPKEY" android:value="$APP_KEY" /> <meta-data android:name="JPUSH_APPKEY" android:value="$APP_KEY" />
</config-file> </config-file>
<source-file src="src/android/libs/jpush-android-3.1.0.jar" target-dir="libs" /> <source-file src="src/android/libs/jpush-android-3.1.1.jar" target-dir="libs" />
<source-file src="src/android/MyReceiver.java" target-dir="src/cn/jiguang/cordova/push" /> <source-file src="src/android/JPushReceiver.java" target-dir="src/cn/jiguang/cordova/push" />
<source-file src="src/android/JPushPlugin.java" target-dir="src/cn/jiguang/cordova/push" /> <source-file src="src/android/JPushPlugin.java" target-dir="src/cn/jiguang/cordova/push" />
<source-file src="src/android/JPushEventReceiver.java" target-dir="src/cn/jiguang/cordova/push" /> <source-file src="src/android/JPushEventReceiver.java" target-dir="src/cn/jiguang/cordova/push" />

View File

@ -11,7 +11,7 @@ import java.util.Map;
import cn.jpush.android.api.JPushInterface; import cn.jpush.android.api.JPushInterface;
public class MyReceiver extends BroadcastReceiver { public class JPushReceiver extends BroadcastReceiver {
private static final List<String> IGNORED_EXTRAS_KEYS = private static final List<String> IGNORED_EXTRAS_KEYS =
Arrays.asList( Arrays.asList(
@ -56,17 +56,14 @@ public class MyReceiver extends BroadcastReceiver {
Intent launch = context.getPackageManager().getLaunchIntentForPackage( Intent launch = context.getPackageManager().getLaunchIntentForPackage(
context.getPackageName()); context.getPackageName());
launch.addCategory(Intent.CATEGORY_LAUNCHER); if (launch != null) {
launch.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP); launch.addCategory(Intent.CATEGORY_LAUNCHER);
context.startActivity(launch); launch.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
context.startActivity(launch);
}
} }
private void handlingNotificationReceive(Context context, Intent intent) { private void handlingNotificationReceive(Context context, Intent intent) {
Intent launch = context.getPackageManager().getLaunchIntentForPackage(
context.getPackageName());
launch.addCategory(Intent.CATEGORY_LAUNCHER);
launch.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
String title = intent.getStringExtra(JPushInterface.EXTRA_NOTIFICATION_TITLE); String title = intent.getStringExtra(JPushInterface.EXTRA_NOTIFICATION_TITLE);
JPushPlugin.notificationTitle = title; JPushPlugin.notificationTitle = title;

Binary file not shown.