iOS:推送通知未在iOS 10中显示字典信息

iOS:推送通知未在iOS 10中显示字典信息,第1张

概述我正在开发XCode 8 Beta,iOS 10版本的推送通知.我在设备上收到推送通知.当我点击通知时,它触发了UNUserNotificationCenterDelegate的委托,app被打开,但它没有在userinfo中显示任何响应.我是否需要在服务器端更改iOS 10中发送推送的参数.以下是我的代码. UIUserNotificationSettings *settings = [UIUs 我正在开发XCode 8 Beta,iOS 10版本的推送通知.我在设备上收到推送通知.当我点击通知时,它触发了UNUserNotificationCenterDelegate的委托,app被打开,但它没有在userinfo中显示任何响应.我是否需要在服务器端更改iOS 10中发送推送的参数.以下是我的代码.
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;
解决方法
- (voID)userNotificationCenter:(UNUserNotificationCenter *)center       willPresentNotification:(UNNotification *)notification         withCompletionHandler:(voID (^)(UNNotificationPresentationoptions options))completionHandler {    NSLog(@"%@",notification.request.content.userInfo);}- (voID)userNotificationCenter:(UNUserNotificationCenter *)centerdIDReceiveNotificationResponse:(UNNotificationResponse *)response         withCompletionHandler:(voID(^)())completionHandler {    NSLog(@"%@",response.notification.request.content.userInfo);}
总结

以上是内存溢出为你收集整理的iOS:推送通知未在iOS 10中显示字典信息全部内容,希望文章能够帮你解决iOS:推送通知未在iOS 10中显示字典信息所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1102065.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-28
下一篇 2022-05-28

发表评论

登录后才能评论

评论列表(0条)

保存