mirror of
https://github.com/jpush/jpush-phonegap-plugin.git
synced 2025-01-31 22:42:51 +08:00
adjust ios remote notification formate
This commit is contained in:
parent
53e3588937
commit
4780eafb72
@ -44,7 +44,8 @@ NSDictionary *_launchOptions;
|
||||
if (notification.userInfo) {
|
||||
|
||||
if ([notification.userInfo valueForKey:UIApplicationLaunchOptionsRemoteNotificationKey]) {
|
||||
[JPushPlugin fireDocumentEvent:JPushDocumentEvent_OpenNotification jsString:[notification.userInfo toJsonString]];
|
||||
[JPushPlugin fireDocumentEvent:JPushDocumentEvent_OpenNotification
|
||||
jsString:[[self jpushFormatAPNSDic: notification.userInfo[UIApplicationLaunchOptionsRemoteNotificationKey]] toJsonString]];
|
||||
}
|
||||
|
||||
if ([notification.userInfo valueForKey:UIApplicationLaunchOptionsLocalNotificationKey]) {
|
||||
@ -82,6 +83,23 @@ NSDictionary *_launchOptions;
|
||||
[JPushPlugin fireDocumentEvent:JPushDocumentEvent_receiveRegistrationId jsString:[event toJsonString]];
|
||||
}
|
||||
|
||||
- (NSMutableDictionary *)jpushFormatAPNSDic:(NSDictionary *)dic {
|
||||
NSMutableDictionary *extras = @{}.mutableCopy;
|
||||
for (NSString *key in dic) {
|
||||
if([key isEqualToString:@"_j_business"] ||
|
||||
[key isEqualToString:@"_j_msgid"] ||
|
||||
[key isEqualToString:@"_j_uid"] ||
|
||||
[key isEqualToString:@"actionIdentifier"] ||
|
||||
[key isEqualToString:@"aps"]) {
|
||||
continue;
|
||||
}
|
||||
extras[key] = dic[key];
|
||||
}
|
||||
NSMutableDictionary *formatDic = dic.mutableCopy;
|
||||
formatDic[@"extras"] = extras;
|
||||
return formatDic;
|
||||
}
|
||||
|
||||
-(void)registerForRemoteNotification{
|
||||
if ([[UIDevice currentDevice].systemVersion floatValue] >= 10.0) {
|
||||
#ifdef NSFoundationVersionNumber_iOS_9_x_Max
|
||||
@ -130,7 +148,8 @@ NSDictionary *_launchOptions;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
[JPushPlugin fireDocumentEvent:eventName jsString:[userInfo toJsonString]];
|
||||
|
||||
[JPushPlugin fireDocumentEvent:eventName jsString:[[self jpushFormatAPNSDic:userInfo] toJsonString]];
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(30 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
completionHandler(UIBackgroundFetchResultNewData);
|
||||
});
|
||||
@ -140,7 +159,7 @@ NSDictionary *_launchOptions;
|
||||
NSMutableDictionary *userInfo = @[].mutableCopy;
|
||||
|
||||
if ([notification.request.trigger isKindOfClass:[UNPushNotificationTrigger class]]) {
|
||||
userInfo = [NSMutableDictionary dictionaryWithDictionary:notification.request.content.userInfo];
|
||||
userInfo = [self jpushFormatAPNSDic:notification.request.content.userInfo];
|
||||
} else {
|
||||
UNNotificationContent *content = notification.request.content;
|
||||
userInfo = [NSMutableDictionary dictionaryWithDictionary:@{@"content": content.body,
|
||||
@ -159,7 +178,7 @@ NSDictionary *_launchOptions;
|
||||
NSMutableDictionary *userInfo = nil;
|
||||
|
||||
if ([notification.request.trigger isKindOfClass:[UNPushNotificationTrigger class]]) {
|
||||
userInfo = [NSMutableDictionary dictionaryWithDictionary:notification.request.content.userInfo];
|
||||
userInfo = [self jpushFormatAPNSDic:notification.request.content.userInfo];
|
||||
} else {
|
||||
UNNotificationContent *content = notification.request.content;
|
||||
userInfo = [NSMutableDictionary dictionaryWithDictionary:@{@"content": content.body,
|
||||
|
Loading…
Reference in New Issue
Block a user