- - (BOOL) application: (UIApplication * ) application didFinishLaunchingWithOptions: (NSDictionary * ) launchOptions {
- //-- Set Notification
- if ([application respondsToSelector: @selector(isRegisteredForRemoteNotifications)]) {
- // iOS 8 Notifications
- [application registerUserNotificationSettings: [UIUserNotificationSettings settingsForTypes: (UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories: nil]]; [application registerForRemoteNotifications];
- } else {
- // iOS < 8 Notifications
- [application registerForRemoteNotificationTypes: (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound)];
- }
- //--- your custom code
- return YES;
- }
来源: http://lib.csdn.net/snippet/ios/42284