mirror of
https://github.com/jpush/jpush-phonegap-plugin.git
synced 2025-04-21 15:56:23 +08:00
add open notification evnet when app is launching
This commit is contained in:
parent
2dbd0cb248
commit
ff86dc1230
@ -14,6 +14,7 @@
|
||||
|
||||
}
|
||||
|
||||
+(void)setLaunchOptions:(NSDictionary *)theLaunchOptions;
|
||||
-(void)setTagsWithAlias:(CDVInvokedUrlCommand*)command;
|
||||
-(void)setTags:(CDVInvokedUrlCommand*)command;
|
||||
-(void)setAlias:(CDVInvokedUrlCommand*)command;
|
||||
|
@ -10,8 +10,16 @@
|
||||
#import "APService.h"
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user