5
在iOS9中,我們會提醒用戶他們是否需要通知並將他們引導至設置頁面,以便他們可以爲我們的應用啓用通知許可。但是,如下所示,在iOS 10中,我無法在我的應用程序權限設置中啓用通知。是否有一個新流程可以用適當的權限填充此列表?如何爲iOS 10啓用通知?
代碼
//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()'應該做的事之後'理所當然== TRUE' – KVISH