Skip to content

Instantly share code, notes, and snippets.

@mamaz
Created May 7, 2015 13:03
Show Gist options
  • Save mamaz/337c696514c4939316f8 to your computer and use it in GitHub Desktop.
Save mamaz/337c696514c4939316f8 to your computer and use it in GitHub Desktop.
Register push notification iOS 8 compliant
- (void)registerForPushNotifications
{
UIApplication *sharedApplication = [UIApplication sharedApplication];
if ([sharedApplication respondsToSelector:@selector(registerUserNotificationSettings:)]) {
UIUserNotificationType type = (UIUserNotificationTypeSound|UIUserNotificationTypeAlert|UIUserNotificationTypeBadge);
UIUserNotificationSettings *notificationSettings = [UIUserNotificationSettings settingsForTypes:type
categories:nil];
[sharedApplication registerUserNotificationSettings:notificationSettings];
[sharedApplication registerForRemoteNotifications];
}
else {
UIRemoteNotificationType remoteNotificationType = (UIRemoteNotificationTypeBadge|UIRemoteNotificationTypeSound| UIRemoteNotificationTypeAlert);
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:remoteNotificationType];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment