iOS:推送通知在iOS 10中不显示字典信息
我正在处理XCode 8 Beta版、iOS 10版中的推送通知。我已收到设备上的推送通知。当我点击通知时,它触发了UnuseNotificationCenterDelegate的委托,应用程序被打开,但在userinfo中没有显示任何响应。我是否需要更改服务器端发送推入式iOS 10的参数。下面是我的代码iOS:推送通知在iOS 10中不显示字典信息,ios,objective-c,iphone,apple-push-notifications,ios10,Ios,Objective C,Iphone,Apple Push Notifications,Ios10,我正在处理XCode 8 Beta版、iOS 10版中的推送通知。我已收到设备上的推送通知。当我点击通知时,它触发了UnuseNotificationCenterDelegate的委托,应用程序被打开,但在userinfo中没有显示任何响应。我是否需要更改服务器端发送推入式iOS 10的参数。下面是我的代码 UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:UIUserN
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound categories:nil];
[application registerUserNotificationSettings:settings];
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
center.delegate = self;
[center requestAuthorizationWithOptions:(UNAuthorizationOptionBadge | UNAuthorizationOptionSound | UNAuthorizationOptionAlert) completionHandler:^(BOOL granted, NSError * _Nullable error) {
if (!error) {
NSLog(@"request authorization succeeded!");
}
}];
- (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler {
NSLog(@"Notification is triggered");
completionHandler(UNNotificationPresentationOptionAlert);
}
- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void(^)())completionHandler {
NSLog(@"Tapped in notification");
NSLog(@"%@",response.notification);
NSString *actionIdentifier = response.actionIdentifier;
if ([actionIdentifier isEqualToString:@"com.apple.UNNotificationDefaultActionIdentifier"] ||
[actionIdentifier isEqualToString:@"com.apple.UNNotificationDismissActionIdentifier"]) {
return;
}
}
在iOS 9中
aps = {
alert = "Multi extra param push.";
badge = 0;
sound = default;
};
t = I;
url = "http://www.google.com";
在iOS 10中
alert = "Multi extra param push.";
badge = 0;
sound = default;
为什么要使用beta iOS版本?请尝试此NSLog(@“%@,[response.notification.request.content.userInfo objectForKey:@“aps”);在iOS 9中,aps={alert=“Multi-extra-param-push.”badge=0;sound=default;};t=I;url=“”;在iOS 10中,alert=“多额外参数推送。”;badge=0;声音=默认值;我没有在iOS 10中获得url和t值,是否有任何方法可以检索或我需要更改任何东西。我得到了解决方案如何做,感谢所有的帮助
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
willPresentNotification:(UNNotification *)notification
withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler {
NSLog(@"%@", notification.request.content.userInfo);
}
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
didReceiveNotificationResponse:(UNNotificationResponse *)response
withCompletionHandler:(void(^)())completionHandler {
NSLog(@"%@", response.notification.request.content.userInfo);
}