mirror of
https://github.com/jpush/jpush-phonegap-plugin.git
synced 2025-01-19 13:52:49 +08:00
fix local notification event in ios 10
This commit is contained in:
parent
9ea65add1f
commit
f50a8ea5c7
@ -43,7 +43,7 @@ export class HomePage {
|
|||||||
} else {
|
} else {
|
||||||
content = event.aps.alert;
|
content = event.aps.alert;
|
||||||
}
|
}
|
||||||
console.log('Receive notification: ' + content);
|
alert('Receive notification: ' + JSON.stringify(event));
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
document.addEventListener('jpush.openNotification', (event: any) => {
|
document.addEventListener('jpush.openNotification', (event: any) => {
|
||||||
@ -53,7 +53,8 @@ export class HomePage {
|
|||||||
} else {
|
} else {
|
||||||
content = event.aps.alert;
|
content = event.aps.alert;
|
||||||
}
|
}
|
||||||
alert('Open notification: ' + content);
|
// alert('Open notification: ' + content);
|
||||||
|
alert('open notification: ' + JSON.stringify(event));
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
document.addEventListener('jpush.receiveLocalNotification', (event: any) => {
|
document.addEventListener('jpush.receiveLocalNotification', (event: any) => {
|
||||||
|
@ -137,19 +137,38 @@ NSDictionary *_launchOptions;
|
|||||||
}
|
}
|
||||||
|
|
||||||
-(void)jpushNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(NSInteger))completionHandler{
|
-(void)jpushNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(NSInteger))completionHandler{
|
||||||
NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithDictionary:notification.request.content.userInfo];
|
NSMutableDictionary *userInfo = @[].mutableCopy;
|
||||||
[JPushPlugin fireDocumentEvent:JPushDocumentEvent_ReceiveNotification jsString:[userInfo toJsonString]];
|
|
||||||
completionHandler(UNNotificationPresentationOptionBadge|UNNotificationPresentationOptionSound|UNNotificationPresentationOptionAlert);
|
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{
|
-(void)jpushNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)())completionHandler{
|
||||||
NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithDictionary:response.notification.request.content.userInfo];
|
UNNotification *notification = response.notification;
|
||||||
@try {
|
NSMutableDictionary *userInfo = nil;
|
||||||
[userInfo setValue:[response valueForKey:@"userText"] forKey:@"userText"];
|
|
||||||
} @catch (NSException *exception) { }
|
if ([notification.request.trigger isKindOfClass:[UNPushNotificationTrigger class]]) {
|
||||||
[userInfo setValue:response.actionIdentifier forKey:@"actionIdentifier"];
|
userInfo = [NSMutableDictionary dictionaryWithDictionary:notification.request.content.userInfo];
|
||||||
[JPushPlugin fireDocumentEvent:JPushDocumentEvent_OpenNotification jsString:[userInfo toJsonString]];
|
} else {
|
||||||
completionHandler();
|
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 {
|
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {
|
||||||
|
Loading…
Reference in New Issue
Block a user