How to verify that notifications are enabled on iPhone

How to check if notification is enabled on iPhone? I install the application, the application says to confirm, to activate the push notification for the application, and click OK. But if notification is disabled on the iPhone, this action does not include notifications. How to check it?

+4
source share
2 answers

This should work:

UIRemoteNotificationType types = [[UIApplication sharedApplication] enabledRemoteNotificationTypes]; if (types == UIRemoteNotificationTypeNone) // Disabled 
+8
source

This has changed in iOS8. To support iOS8 and below, run

 + (BOOL)notificationServicesEnabled { BOOL isEnabled = NO; if ([[UIApplication sharedApplication] respondsToSelector:@selector(currentUserNotificationSettings)]){ UIUserNotificationSettings *notificationSettings = [[UIApplication sharedApplication] currentUserNotificationSettings]; if (!notificationSettings || (notificationSettings.types == UIUserNotificationTypeNone)) { isEnabled = NO; } else { isEnabled = YES; } } else { UIRemoteNotificationType types = [[UIApplication sharedApplication] enabledRemoteNotificationTypes]; if (types & UIRemoteNotificationTypeAlert) { isEnabled = YES; } else{ isEnabled = NO; } } return isEnabled; } 
+3
source

Source: https://habr.com/ru/post/1392978/


All Articles