This works fine running in iOS8, but when I put it on an iOS7 device, it crashes giving me the error
-[UIApplication registerUserNotificationSettings:]: unrecognized selector sent to instance 0x14e56e20
I'm registering for notifications in my AppDelegate:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
#ifdef __IPHONE_8_0
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:(UIRemoteNotificationTypeBadge
|UIRemoteNotificationTypeSound
|UIRemoteNotificationTypeAlert) categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:settings];
#else
//register to receive notifications
UIRemoteNotificationType myTypes = UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound;
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:myTypes];
#endif
application.applicationIconBadgeNumber = 0;
return YES;
}
When I set a breakpoint, it always runs the code in the __IPHONE_8_0 block. How else can I detect which block to run?