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中显示字典信息所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)