In iOS9 we prompt our user if they'd like notifications and direct them to the settings page so they can enable notification permission for our app. However as shown below there is no option to enable notifications in my apps permissions settings within iOS 10. Is there a new process I must undertake to populate this list with the appropriate permissions?
Code
//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()
}
}
iOS 10 has introduced UNUserNotificationCenter, which is used now for all local and push notifications. For example:
UNUserNotificationCenter.current().requestAuthorization(options: [.alert])
{ (granted, error) in
if granted == true{
NSLog("Granted")
UIApplication.shared.registerForRemoteNotifications()
}
if let error = error {
NSLog("Error: \(error.description)")
}
}
You can check the settings using getNotificationSettings()
WWDC video: https://developer.apple.com/videos/play/wwdc2016/707/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With