Created
July 14, 2014 03:28
-
-
Save higepon/984a4cd5715f89980e1a to your computer and use it in GitHub Desktop.
iOS7 and iOS8 Compatible Push Notifications Registrations
This file contains 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
#import <Foundation/Foundation.h> | |
@interface Compatible : NSObject | |
+ (void)registerPush:(UIApplication *)application; | |
@end |
This file contains 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
#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