Skip to content

Instantly share code, notes, and snippets.

@higepon
Created July 14, 2014 03:28
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 higepon/984a4cd5715f89980e1a to your computer and use it in GitHub Desktop.
Save higepon/984a4cd5715f89980e1a to your computer and use it in GitHub Desktop.
iOS7 and iOS8 Compatible Push Notifications Registrations
#import <Foundation/Foundation.h>
@interface Compatible : NSObject
+ (void)registerPush:(UIApplication *)application;
@end
#import <UIKit/UIKit.h>
#import "Compatible.h"
@implementation Compatible
+ (void)registerPush:(UIApplication *)application {
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000
if ([application respondsToSelector:@selector(registerUserNotificationSettings:)]) {
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound categories:nil];
[application registerUserNotificationSettings:settings];
[application registerForRemoteNotifications];
} else {
[application registerForRemoteNotificationTypes: UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge];
}
#else
[application registerForRemoteNotificationTypes: UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge];
#endif
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment