Created
May 7, 2015 13:03
-
-
Save mamaz/337c696514c4939316f8 to your computer and use it in GitHub Desktop.
Register push notification iOS 8 compliant
This file contains hidden or 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
- (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