Skip to content

Commit

Permalink
Fix for IOS 8
Browse files Browse the repository at this point in the history
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: facebook#1613 and it was part of  facebook#1979. (is being separated to keep things moving)

Please let me know what you think.Closes facebook#2332

Reviewed By: @​svcscm

Differential Revision: D2490987

Pulled By: @ericvicenti
  • Loading branch information
DannyvanderJagt authored and udfalkso committed Oct 7, 2015
1 parent e3e8d19 commit 6c71ebe
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions Libraries/PushNotificationIOS/RCTPushNotificationManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 6c71ebe

Please sign in to comment.