Skip to content

Instantly share code, notes, and snippets.

@tony0x59
Created February 24, 2016 06:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tony0x59/b468e8c060719bc3f7d6 to your computer and use it in GitHub Desktop.
Save tony0x59/b468e8c060719bc3f7d6 to your computer and use it in GitHub Desktop.
- (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