mirror of
https://github.com/jpush/jpush-phonegap-plugin.git
synced 2026-04-19 00:03:45 +08:00
fix local notification event in ios 10
This commit is contained in:
@@ -137,19 +137,38 @@ NSDictionary *_launchOptions;
|
||||
}
|
||||
|
||||
-(void)jpushNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(NSInteger))completionHandler{
|
||||
NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithDictionary:notification.request.content.userInfo];
|
||||
[JPushPlugin fireDocumentEvent:JPushDocumentEvent_ReceiveNotification jsString:[userInfo toJsonString]];
|
||||
completionHandler(UNNotificationPresentationOptionBadge|UNNotificationPresentationOptionSound|UNNotificationPresentationOptionAlert);
|
||||
NSMutableDictionary *userInfo = @[].mutableCopy;
|
||||
|
||||
if ([notification.request.trigger isKindOfClass:[UNPushNotificationTrigger class]]) {
|
||||
userInfo = [NSMutableDictionary dictionaryWithDictionary:notification.request.content.userInfo];
|
||||
} else {
|
||||
UNNotificationContent *content = notification.request.content;
|
||||
userInfo = @{@"content": content.body,
|
||||
@"badge": content.badge,
|
||||
@"extras": content.userInfo
|
||||
};
|
||||
}
|
||||
|
||||
[JPushPlugin fireDocumentEvent:JPushDocumentEvent_ReceiveNotification jsString:[userInfo toJsonString]];
|
||||
completionHandler(UNNotificationPresentationOptionBadge|UNNotificationPresentationOptionSound|UNNotificationPresentationOptionAlert);
|
||||
}
|
||||
|
||||
-(void)jpushNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)())completionHandler{
|
||||
NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithDictionary:response.notification.request.content.userInfo];
|
||||
@try {
|
||||
[userInfo setValue:[response valueForKey:@"userText"] forKey:@"userText"];
|
||||
} @catch (NSException *exception) { }
|
||||
[userInfo setValue:response.actionIdentifier forKey:@"actionIdentifier"];
|
||||
[JPushPlugin fireDocumentEvent:JPushDocumentEvent_OpenNotification jsString:[userInfo toJsonString]];
|
||||
completionHandler();
|
||||
UNNotification *notification = response.notification;
|
||||
NSMutableDictionary *userInfo = nil;
|
||||
|
||||
if ([notification.request.trigger isKindOfClass:[UNPushNotificationTrigger class]]) {
|
||||
userInfo = [NSMutableDictionary dictionaryWithDictionary:notification.request.content.userInfo];
|
||||
} else {
|
||||
UNNotificationContent *content = notification.request.content;
|
||||
userInfo = [NSMutableDictionary dictionaryWithDictionary:@{@"content": content.body,
|
||||
@"badge": content.badge,
|
||||
@"extras": content.userInfo
|
||||
}];
|
||||
}
|
||||
userInfo[@"actionIdentifier"] = response.actionIdentifier;
|
||||
[JPushPlugin fireDocumentEvent:JPushDocumentEvent_OpenNotification jsString:[userInfo toJsonString]];
|
||||
completionHandler();
|
||||
}
|
||||
|
||||
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {
|
||||
|
||||
Reference in New Issue
Block a user