diff --git a/src/ios/Plugins/JPushPlugin.h b/src/ios/Plugins/JPushPlugin.h index 3f2d77f..605f420 100644 --- a/src/ios/Plugins/JPushPlugin.h +++ b/src/ios/Plugins/JPushPlugin.h @@ -14,6 +14,7 @@ } ++(void)setLaunchOptions:(NSDictionary *)theLaunchOptions; -(void)setTagsWithAlias:(CDVInvokedUrlCommand*)command; -(void)setTags:(CDVInvokedUrlCommand*)command; -(void)setAlias:(CDVInvokedUrlCommand*)command; diff --git a/src/ios/Plugins/JPushPlugin.m b/src/ios/Plugins/JPushPlugin.m index 0697040..6dd503d 100644 --- a/src/ios/Plugins/JPushPlugin.m +++ b/src/ios/Plugins/JPushPlugin.m @@ -10,8 +10,16 @@ #import "APService.h" #import +static NSDictionary *_luanchOptions=nil; + @implementation JPushPlugin + ++(void)setLaunchOptions:(NSDictionary *)theLaunchOptions{ + _luanchOptions=theLaunchOptions; + +} + - (CDVPlugin*)initWithWebView:(UIWebView*)theWebView{ if (self=[super initWithWebView:theWebView]) { @@ -26,7 +34,21 @@ name:kJPushPluginReceiveNotification object:nil]; + NSDictionary *userInfo = [_luanchOptions + valueForKey:UIApplicationLaunchOptionsRemoteNotificationKey]; + if (_luanchOptions && [userInfo count] >0) { + NSError *error; + NSData *jsonData = [NSJSONSerialization dataWithJSONObject:userInfo options:0 error:&error]; + NSString *jsonString = [[NSString alloc]initWithData:jsonData encoding:NSUTF8StringEncoding]; + if (!error) { + + dispatch_async(dispatch_get_main_queue(), ^{ + [self.commandDelegate evalJs:[NSString stringWithFormat:@"cordova.fireDocumentEvent('jpush.openNotification',%@)",jsonString]]; + }); + + } + } } return self; }