I can check if user granted notification (alert) permission or not before iOS8 like that:
UIRemoteNotificationType types = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
if (types & UIRemoteNotificationTypeAlert)
{
//user granted
}
it is not working on iOS8, it says:
iOS (3.0 and later) Deprecated:Register for user notification settings using the registerUserNotificationSettings: method instead.
console says:
enabledRemoteNotificationTypes is not supported in iOS 8.0 and later.
so how can I check it on iOS 8?
I expanded on woheras answer a bit to be more dynamic
Trying to shoot two birds with one stone here. First, instead of checking for isRegisteredForRemoteNotifications(), you should probably check for currentUserNotificationSettings(). With that, you can see if Alerts, Sound, etc are allowed. Secondly, it seems like the iOS version check is redundant here. Simply checking if object responds to selector is good enough. Lastly, the code example is in Swift, for that one user who asked for it :P
Here is how to do Daniels answer in Swift 2.0
Ok I solved my problem like this:
I didn't have much luck using
isRegisteredForNotifications
. I ended up usingcurrentUserNotificationSettings
instead.