mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-29 12:45:37 +08:00
Fix for IOS 8
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
This commit is contained in:
committed by
facebook-github-bot-5
parent
4bb58e59f7
commit
200b81172e
@@ -157,13 +157,13 @@ RCT_EXPORT_METHOD(requestPermissions:(NSDictionary *)permissions)
|
|||||||
}
|
}
|
||||||
|
|
||||||
UIApplication *app = RCTSharedApplication();
|
UIApplication *app = RCTSharedApplication();
|
||||||
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_8_0
|
if ([app respondsToSelector:@selector(registerUserNotificationSettings:)]) {
|
||||||
id notificationSettings = [UIUserNotificationSettings settingsForTypes:types categories:nil];
|
UIUserNotificationSettings *notificationSettings = [UIUserNotificationSettings settingsForTypes:(NSUInteger)types categories:nil];
|
||||||
[app registerUserNotificationSettings:notificationSettings];
|
[app registerUserNotificationSettings:notificationSettings];
|
||||||
[app registerForRemoteNotifications];
|
[app registerForRemoteNotifications];
|
||||||
#else
|
} else {
|
||||||
[app registerForRemoteNotificationTypes:types];
|
[app registerForRemoteNotificationTypes:(NSUInteger)types];
|
||||||
#endif
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RCT_EXPORT_METHOD(abandonPermissions)
|
RCT_EXPORT_METHOD(abandonPermissions)
|
||||||
|
|||||||
Reference in New Issue
Block a user