diff --git a/README.md b/README.md index 43685e4..7078c8e 100644 --- a/README.md +++ b/README.md @@ -86,6 +86,9 @@ - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo { // Required [APService handleRemoteNotification:userInfo]; + [[NSNotificationCenter defaultCenter] postNotificationName:kJPushPluginReceiveNotification + object:userInfo]; + } ###Android 手工安装### diff --git a/example/index.html b/example/index.html index cc4adb1..8467176 100644 --- a/example/index.html +++ b/example/index.html @@ -37,6 +37,16 @@ console.log(exception) } } + var onReceiveNotification = function(event){ + try{ + var alert = event.aps.alert; + console.log("JPushPlugin:onReceiveNotification key aps.alert:"+aps); + } + catch(exeption){ + console.log(exception) + } + } + var onGetRegistradionID = function(data) { try{ console.log("JPushPlugin:registrationID is "+data) @@ -102,10 +112,11 @@ } }) } + document.addEventListener("jpush.receiveNotification", onReceiveNotification, false); document.addEventListener("jpush.setTagsWithAlias", onTagsWithAlias, false); document.addEventListener("deviceready", onDeviceReady, false); - document.addEventListener("jpush.openNotification", onOpenNotification, false); - + document.addEventListener("jpush.openNotification", onOpenNotification, false); + diff --git a/src/ios/Plugins/JPushPlugin.h b/src/ios/Plugins/JPushPlugin.h index 8a323ea..3f2d77f 100644 --- a/src/ios/Plugins/JPushPlugin.h +++ b/src/ios/Plugins/JPushPlugin.h @@ -8,6 +8,8 @@ #import +#define kJPushPluginReceiveNotification @"JPushPluginReceiveNofication" + @interface JPushPlugin : CDVPlugin{ } diff --git a/src/ios/Plugins/JPushPlugin.m b/src/ios/Plugins/JPushPlugin.m index 45c2a13..648880d 100644 --- a/src/ios/Plugins/JPushPlugin.m +++ b/src/ios/Plugins/JPushPlugin.m @@ -20,6 +20,7 @@ name:kJPFNetworkDidReceiveMessageNotification object:nil]; + } return self; }