iOS iOS8中 問題"registerForRemoteNotificationTypes: is not supported in iOS 8.0 and later" 解決方案
問題重述:
iOS 8中改變了通知註冊的方式,如果App需要同時支援iOS 7 和 8 的話,需要首先檢查selector。
解決方案:在Xcode 6中
- (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;}