I've got the following code in my app - and I see some crashes on iOS 7 in the line with the comment.
+ (void)registerDeviceForRemoteNotifications {
#if !TARGET_IPHONE_SIMULATOR
if ([[KOAAuthenticator sharedAuthenticator] currentUser] != nil) {
UIApplication *sharedApplication = [UIApplication sharedApplication];
#ifdef __IPHONE_8_0
[sharedApplication registerForRemoteNotifications]; // <--- CRASH HERE
#else
[sharedApplication registerForRemoteNotificationTypes:UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert];
#endif
}
#endif
}
Crashlytics says: -[UIApplication registerForRemoteNotifications]: unrecognized selector sent to instance 0x157d04290
how's that even possible? This code shouldn't be called on iOS 7, right?
EDIT: solution
+ (void)registerDeviceForRemoteNotifications {
#if !TARGET_IPHONE_SIMULATOR
if ([[KOAAuthenticator sharedAuthenticator] currentUser] != nil) {
UIApplication *sharedApplication = [UIApplication sharedApplication];
#ifdef __IPHONE_8_0
if ([sharedApplication respondsToSelector:@selector(registerForRemoteNotifications)]) {
[sharedApplication registerForRemoteNotifications];
} else {
[sharedApplication registerForRemoteNotificationTypes:UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert];
}
#else
[sharedApplication registerForRemoteNotificationTypes:UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert];
#endif
}
#endif
}