From 200b81172e396cc5a7bb942c3de6bf3077dce5a6 Mon Sep 17 00:00:00 2001 From: Danny van der Jagt Date: Wed, 30 Sep 2015 18:08:54 -0700 Subject: [PATCH] Fix for IOS 8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: **Problem** Using push notifications in IOS 8 will throw this error: `registerForRemoteNotificationTypes: is not supported in iOS 8.0 and later.` The problem is that the check is running on compile instead of runtime. **Solution** If have changed the compile if statement to a runtime if statement. The fix is tested on: IOS 7.1 and 8.* and everything is working now. This solution is also discussed in: https://github.com/facebook/react-native/issues/1613 and it was part of https://github.com/facebook/react-native/pull/1979. (is being separated to keep things moving) Please let me know what you think.Closes https://github.com/facebook/react-native/pull/2332 Reviewed By: @​svcscm Differential Revision: D2490987 Pulled By: @ericvicenti --- .../RCTPushNotificationManager.m | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Libraries/PushNotificationIOS/RCTPushNotificationManager.m b/Libraries/PushNotificationIOS/RCTPushNotificationManager.m index 6af5f8e91fa7a4..3e45add4477a3c 100644 --- a/Libraries/PushNotificationIOS/RCTPushNotificationManager.m +++ b/Libraries/PushNotificationIOS/RCTPushNotificationManager.m @@ -157,13 +157,13 @@ - (void)handleRemoteNotificationsRegistered:(NSNotification *)notification } UIApplication *app = RCTSharedApplication(); -#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_8_0 - id notificationSettings = [UIUserNotificationSettings settingsForTypes:types categories:nil]; - [app registerUserNotificationSettings:notificationSettings]; - [app registerForRemoteNotifications]; -#else - [app registerForRemoteNotificationTypes:types]; -#endif + if ([app respondsToSelector:@selector(registerUserNotificationSettings:)]) { + UIUserNotificationSettings *notificationSettings = [UIUserNotificationSettings settingsForTypes:(NSUInteger)types categories:nil]; + [app registerUserNotificationSettings:notificationSettings]; + [app registerForRemoteNotifications]; + } else { + [app registerForRemoteNotificationTypes:(NSUInteger)types]; + } } RCT_EXPORT_METHOD(abandonPermissions)