【发布时间】:2014-10-02 08:10:56
【问题描述】:
关于iOS8中用户接受推送通知(以及徽章等通知)变化的两个问题。
1) 我正在使用当前的方法,在 iOS7 和 iOS8 上都可以正常工作
if ([[[UIDevice currentDevice] systemVersion] floatValue]>= 8.0) {
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:
(UIUserNotificationTypeBadge|UIUserNotificationTypeSound|UIUserNotificationTypeAlert)
categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:settings];
[[UIApplication sharedApplication] registerForRemoteNotifications];
} else {
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:
(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
}
这完全可以正常工作,因为 push 和 alert 正在工作,并且我在 didRegister 委托方法中获得了令牌,但从来没有像以前那样弹出窗口询问我。即使我从手机中完全删除该应用程序? 为什么?操作系统是否会保留应用程序的内存隐私设置,即使它们已被删除?
2) 我看到有人建议在以下代表中请求远程通知
- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
{
NSLog(@"registered for notifications settings %@",notificationSettings);
//register to receive notifications
[application registerForRemoteNotifications];
}
为什么?
【问题讨论】:
标签: ios permissions ios8 push-notification