Skip to content

Instantly share code, notes, and snippets.

@akozlik
Created January 27, 2015 15:10
Show Gist options
  • Save akozlik/12521fe329c69f28f9e9 to your computer and use it in GitHub Desktop.
Save akozlik/12521fe329c69f28f9e9 to your computer and use it in GitHub Desktop.
iOS 7 and 8 notification backwards compatibility
UIUserNotificationType userNotificationTypes = (UIUserNotificationTypeAlert |
UIUserNotificationTypeBadge |
UIUserNotificationTypeSound);
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:userNotificationTypes
categories:nil];
if ([application respondsToSelector:@selector(registerUserNotificationSettings:)]) {
[application registerUserNotificationSettings:settings];
[application registerForRemoteNotifications];
} else {
UIRemoteNotificationType myTypes = UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound;
[application registerForRemoteNotificationTypes:myTypes];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment