Determine on iPhone if user has enabled push notifications Determine on iPhone if user has enabled push notifications ios ios

Determine on iPhone if user has enabled push notifications


Call enabledRemoteNotificationsTypes and check the mask.

For example:

UIRemoteNotificationType types = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];if (types == UIRemoteNotificationTypeNone)    // blah blah blah

iOS8 and above:

[[UIApplication sharedApplication] isRegisteredForRemoteNotifications]


quantumpotato's issue:

Where types is given by

UIRemoteNotificationType types = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];

one can use

if (types & UIRemoteNotificationTypeAlert)

instead of

if (types == UIRemoteNotificationTypeNone) 

will allow you to check only whether notifications are enabled (and don't worry about sounds, badges, notification center, etc.). The first line of code (types & UIRemoteNotificationTypeAlert) will return YES if "Alert Style" is set to "Banners" or "Alerts", and NO if "Alert Style" is set to "None", irrespective of other settings.


In the latest version of iOS this method is now deprecated. To support both iOS 7 and iOS 8 use:

UIApplication *application = [UIApplication sharedApplication];BOOL enabled;// Try to use the newer isRegisteredForRemoteNotifications otherwise use the enabledRemoteNotificationTypes.if ([application respondsToSelector:@selector(isRegisteredForRemoteNotifications)]){    enabled = [application isRegisteredForRemoteNotifications];}else{    UIRemoteNotificationType types = [application enabledRemoteNotificationTypes];    enabled = types & UIRemoteNotificationTypeAlert;}