I am trying to detect the Local notification settings for the App in iOS 8
for UIUserNotificationSettings
, it returns me 7 as I have turned on all Badge
Using .isRegisteredForRemoteNotifications()
doesn't work (though it should). However, when the notifications are disabled or one of the type is not present, the following code does work.
func notificationsAreOk() -> Bool {
let wishedTypes = UIUserNotificationType.Badge |
UIUserNotificationType.Alert |
UIUserNotificationType.Sound;
let application = UIApplication.sharedApplication()
let settings = application.currentUserNotificationSettings()
if settings == nil {
return false
}
if settings.types != wishedTypes {
return false
}
return true
}
EDIT: after some tests is does not always work when notifications are disabled. I am considering to send a test notification to know when they work.