El código #ifdef __IPHONE_8_0 también se ejecuta en iOS 7
Tengo el siguiente código en mi aplicación, y veo algunos bloqueos en iOS 7 en la línea con el comentario.
+ (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 dice:-[UIApplication registerForRemoteNotifications]: unrecognized selector sent to instance 0x157d04290
¿Cómo es eso posible? Este código no debería llamarse en iOS 7, ¿verdad?
EDITAR: solución
+ (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
}