add jpush.receiveNotificaiton event in platform android

This commit is contained in:
zhangqinghe
2015-06-09 15:48:51 +08:00
parent c90c9b7b01
commit c420ae20e5
4 changed files with 72 additions and 10 deletions
+15
View File
@@ -23,6 +23,7 @@ public class MyReceiver extends BroadcastReceiver {
} else if (JPushInterface.ACTION_MESSAGE_RECEIVED.equals(intent.getAction())) {
handlingReceivedMessage(intent);
} else if (JPushInterface.ACTION_NOTIFICATION_RECEIVED.equals(intent.getAction())) {
handlingNotificationReceive(context,intent);
} else if (JPushInterface.ACTION_NOTIFICATION_OPENED.equals(intent.getAction())) {
handlingNotificationOpen(context,intent);
@@ -37,6 +38,7 @@ public class MyReceiver extends BroadcastReceiver {
String msg = intent.getStringExtra(JPushInterface.EXTRA_MESSAGE);
Map<String,Object> extras = getNotificationExtras(intent);
JPushPlugin.transmitPush(msg, extras);
}
private void handlingNotificationOpen(Context context,Intent intent){
@@ -54,6 +56,19 @@ public class MyReceiver extends BroadcastReceiver {
context.startActivity(launch);
}
private void handlingNotificationReceive(Context context,Intent intent){
String alert = intent.getStringExtra(JPushInterface.EXTRA_ALERT);
Map<String,Object> extras = getNotificationExtras(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);
JPushPlugin.notificationAlert = alert;
JPushPlugin.notificationExtras = extras;
JPushPlugin.transmitReceive(alert, extras);
}
private Map<String, Object> getNotificationExtras(Intent intent) {
Map<String, Object> extrasMap = new HashMap<String, Object>();