Merge pull request #278 from jpush/dev

fix open local notification to launch app event bug
This commit is contained in:
huangminlinux 2017-10-11 01:43:19 -05:00 committed by GitHub
commit a9343ac776

View File

@ -42,16 +42,24 @@ NSDictionary *_launchOptions;
if (notification) { if (notification) {
if (notification.userInfo) { if (notification.userInfo) {
NSDictionary *userInfo1 = [notification.userInfo valueForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
if (userInfo1.count > 0) { if ([notification.userInfo valueForKey:UIApplicationLaunchOptionsRemoteNotificationKey]) {
[NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(fireOpenNotification:) userInfo:userInfo1 repeats:YES]; [NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(fireOpenNotification:)
userInfo:[notification.userInfo
valueForKey:UIApplicationLaunchOptionsRemoteNotificationKey] repeats:YES];
} }
NSDictionary *userInfo2 = [notification.userInfo valueForKey:UIApplicationLaunchOptionsLocalNotificationKey]; if ([notification.userInfo valueForKey:UIApplicationLaunchOptionsLocalNotificationKey]) {
if (userInfo2.count > 0) { UILocalNotification *localNotification = [notification.userInfo valueForKey:UIApplicationLaunchOptionsLocalNotificationKey];
[NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(fireOpenNotification:) userInfo:userInfo2 repeats:YES];
NSDictionary* localNotificationEvent = @{@"content":localNotification.alertBody,
@"badge": @(localNotification.applicationIconBadgeNumber),
@"extras":localNotification.userInfo,
};
[NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(fireOpenNotification:) userInfo:localNotificationEvent repeats:YES];
} }
} }
[JPUSHService setDebugMode]; [JPUSHService setDebugMode];
NSString *plistPath = [[NSBundle mainBundle] pathForResource:JPushConfig_FileName ofType:@"plist"]; NSString *plistPath = [[NSBundle mainBundle] pathForResource:JPushConfig_FileName ofType:@"plist"];