Merge pull request #335 from jpush/dev

Dev
This commit is contained in:
huangminlinux 2018-04-16 15:15:14 +08:00 committed by GitHub
commit a0e408f05f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 20 deletions

View File

@ -51,11 +51,11 @@ NSDictionary *_launchOptions;
if ([notification.userInfo valueForKey:UIApplicationLaunchOptionsLocalNotificationKey]) { if ([notification.userInfo valueForKey:UIApplicationLaunchOptionsLocalNotificationKey]) {
UILocalNotification *localNotification = [notification.userInfo valueForKey:UIApplicationLaunchOptionsLocalNotificationKey]; UILocalNotification *localNotification = [notification.userInfo valueForKey:UIApplicationLaunchOptionsLocalNotificationKey];
NSMutableDictionary *localNotificationEvent = @{}.mutableCopy;
localNotificationEvent[@"content"] = localNotification.alertBody;
localNotificationEvent[@"badge"] = @(localNotification.applicationIconBadgeNumber);
localNotificationEvent[@"extras"] = localNotification.userInfo;
NSDictionary* localNotificationEvent = @{@"content":localNotification.alertBody,
@"badge": @(localNotification.applicationIconBadgeNumber),
@"extras":localNotification.userInfo,
};
[JPushPlugin fireDocumentEvent:JPushDocumentEvent_OpenNotification jsString:[localNotificationEvent toJsonString]]; [JPushPlugin fireDocumentEvent:JPushDocumentEvent_OpenNotification jsString:[localNotificationEvent toJsonString]];
} }
} }
@ -158,10 +158,9 @@ NSDictionary *_launchOptions;
userInfo = [self jpushFormatAPNSDic:notification.request.content.userInfo]; userInfo = [self jpushFormatAPNSDic:notification.request.content.userInfo];
} else { } else {
UNNotificationContent *content = notification.request.content; UNNotificationContent *content = notification.request.content;
userInfo = [NSMutableDictionary dictionaryWithDictionary:@{@"content": content.body, userInfo[@"content"] = content.body;
@"badge": content.badge, userInfo[@"badge"] = content.badge;
@"extras": content.userInfo userInfo[@"extras"] = content.userInfo;
}];
userInfo[@"identifier"] = notification.request.identifier; userInfo[@"identifier"] = notification.request.identifier;
} }
@ -177,16 +176,15 @@ NSDictionary *_launchOptions;
-(void)jpushNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)())completionHandler{ -(void)jpushNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)())completionHandler{
UNNotification *notification = response.notification; UNNotification *notification = response.notification;
NSMutableDictionary *userInfo = nil; NSMutableDictionary *userInfo = @{}.mutableCopy;
if ([notification.request.trigger isKindOfClass:[UNPushNotificationTrigger class]]) { if ([notification.request.trigger isKindOfClass:[UNPushNotificationTrigger class]]) {
userInfo = [self jpushFormatAPNSDic:notification.request.content.userInfo]; userInfo = [self jpushFormatAPNSDic:notification.request.content.userInfo];
} else { } else {
UNNotificationContent *content = notification.request.content; UNNotificationContent *content = notification.request.content;
userInfo = [NSMutableDictionary dictionaryWithDictionary:@{@"content": content.body, userInfo[@"content"] = content.body;
@"badge": content.badge, userInfo[@"badge"] = content.badge;
@"extras": content.userInfo userInfo[@"extras"] = content.userInfo;
}];
userInfo[@"identifier"] = notification.request.identifier; userInfo[@"identifier"] = notification.request.identifier;
} }
@ -195,10 +193,10 @@ NSDictionary *_launchOptions;
} }
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification { - (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {
NSDictionary* localNotificationEvent = @{@"content":notification.alertBody, NSMutableDictionary *localNotificationEvent = @{}.mutableCopy;
@"badge": @(notification.applicationIconBadgeNumber), localNotificationEvent[@"content"] = notification.alertBody;
@"extras":notification.userInfo, localNotificationEvent[@"badge"] = @(notification.applicationIconBadgeNumber);
}; localNotificationEvent[@"extras"] = notification.userInfo;
[[NSNotificationCenter defaultCenter] postNotificationName:JPushDocumentEvent_ReceiveLocalNotification object:localNotificationEvent]; [[NSNotificationCenter defaultCenter] postNotificationName:JPushDocumentEvent_ReceiveLocalNotification object:localNotificationEvent];
} }

View File

@ -353,7 +353,7 @@ JPushPlugin.prototype.reportNotificationOpened = function (msgID) {
/** /**
* 用于在 Android 6.0 及以上系统申请一些权限 * 用于在 Android 6.0 及以上系统申请一些权限
* 具体可看http://docs.jpush.io/client/android_api/#android-60 * 具体可看https://docs.jiguang.cn/jpush/client/Android/android_api/#android-60
*/ */
JPushPlugin.prototype.requestPermission = function () { JPushPlugin.prototype.requestPermission = function () {
if (device.platform === 'Android') { if (device.platform === 'Android') {