È inoltre possibile utilizzare questo codice:
if ([[UIApplication sharedApplication] respondsToSelector:@selector(currentUserNotificationSettings)]) {
UIUserNotificationType types = [[[UIApplication sharedApplication] currentUserNotificationSettings] types];
if (types == UIUserNotificationTypeNone) {
// Do something
}
} else {
UIRemoteNotificationType types = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
if (types == UIRemoteNotificationTypeNone) {
// Do something
}
}
O questo uno se desideri solo controllare l'utente è registrato per le notifiche a distanza:
if ([[UIApplication sharedApplication] respondsToSelector:@selector(isRegisteredForRemoteNotifications)]) {
BOOL isRegisteredForRemoteNotifications = [[UIApplication sharedApplication] isRegisteredForRemoteNotifications];
if (isRegisteredForRemoteNotifications) {
// Do something
}
} else {
UIRemoteNotificationType types = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
if (types == UIRemoteNotificationTypeNone) {
// Do something
}
}
che dire di questo http: // StackOverflow .com/domande/25111644/Detect-allow-notifiche-is-on-off-for-iOS 8? –