在 iOS9 中,我们会提示用户是否需要通知,并引导他们到设置页面以便启用应用的通知权限。然而,在 iOS10 中,如下图所示,在我的应用程序权限设置中没有启用通知的选项。我是否需要采取新的流程来填充具有适当权限的列表?
代码
//check the notifications status. First the global settings of the device, then our stored settings
func checkGlobalNotifications() {
let grantedSettings = UIApplication.sharedApplication().currentUserNotificationSettings()
if grantedSettings!.types.rawValue & UIUserNotificationType.Alert.rawValue != 0 {
globalNotificationsEnabled = true
//if global notifications are on, then check our stored settings (user)
if CallIn.Settings.notificationsEnabled { notificationsOn() } else { notificationsOff() }
}
else {
globalNotificationsEnabled = false
//global notifications (iOS) not allowed by the user so disable them
notificationsOff()
}
}
UIApplication.shared.registerForRemoteNotifications()
应该在granted == true
之后执行。 - KVISH