Created
February 24, 2016 06:25
-
-
Save tony0x59/b468e8c060719bc3f7d6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (BOOL)checkNotificationIsEnabled { | |
UIApplication *application = [UIApplication sharedApplication]; | |
BOOL enabled = NO; | |
// iOS8 and above | |
if ([application respondsToSelector:@selector(isRegisteredForRemoteNotifications)]) { | |
if ([application isRegisteredForRemoteNotifications]) { | |
UIUserNotificationSettings *settings = [[UIApplication sharedApplication] currentUserNotificationSettings]; | |
if (settings.types != UIUserNotificationTypeNone) { | |
enabled = YES; | |
} | |
} | |
} | |
else { | |
UIRemoteNotificationType types = [[UIApplication sharedApplication] enabledRemoteNotificationTypes]; | |
if (types != UIRemoteNotificationTypeNone) { | |
enabled = YES; | |
} | |
} | |
NSLog(@"APNS is %@", @(enabled)); | |
return enabled; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment