Rename methods in RCTPushNotificationManager so app store doesn't warn
Summary: Including RCTPushNotificationManager is required for local notifications, which don't require a Push Notifications entitlement on your provisioning profile. However, if you don't have the entitlement, the app store warns you when you push an app build that contains `application:didRegisterForRemoteNotificationsWithDeviceToken:`, even if it isn't being called. This renames the methods so they have different names from the ones on UIApplication so the app store doesn't warn about them. Closes https://github.com/facebook/react-native/pull/4897 Reviewed By: spicyj Differential Revision: D2780533 Pulled By: nicklockwood fb-gh-sync-id: 1a688f1ebd3cc9f86ba340ce453fdbfb46949839
This commit is contained in:
parent
ee82bad3f7
commit
1dc5dca604
|
@ -39,15 +39,20 @@ var NOTIF_REGISTER_EVENT = 'remoteNotificationsRegistered';
|
|||
* And then in your AppDelegate implementation add the following:
|
||||
*
|
||||
* ```
|
||||
* // Required for the register event.
|
||||
* // Required to register for notifications
|
||||
* - (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
|
||||
* {
|
||||
* [RCTPushNotificationManager didRegisterUserNotificationSettings:notificationSettings];
|
||||
* }
|
||||
* // Required for the register event.
|
||||
* - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
|
||||
* {
|
||||
* [RCTPushNotificationManager application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
|
||||
* [RCTPushNotificationManager didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
|
||||
* }
|
||||
* // Required for the notification event.
|
||||
* - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)notification
|
||||
* {
|
||||
* [RCTPushNotificationManager application:application didReceiveRemoteNotification:notification];
|
||||
* [RCTPushNotificationManager didReceiveRemoteNotification:notification];
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
|
||||
@interface RCTPushNotificationManager : NSObject <RCTBridgeModule>
|
||||
|
||||
+ (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings;
|
||||
+ (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken;
|
||||
+ (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)notification;
|
||||
+ (void)didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings;
|
||||
+ (void)didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken;
|
||||
+ (void)didReceiveRemoteNotification:(NSDictionary *)notification;
|
||||
|
||||
@end
|
||||
|
|
|
@ -71,14 +71,14 @@ RCT_EXPORT_MODULE()
|
|||
return @{@"initialNotification": RCTNullIfNil(initialNotification)};
|
||||
}
|
||||
|
||||
+ (void)application:(__unused UIApplication *)application didRegisterUserNotificationSettings:(__unused UIUserNotificationSettings *)notificationSettings
|
||||
+ (void)didRegisterUserNotificationSettings:(__unused UIUserNotificationSettings *)notificationSettings
|
||||
{
|
||||
if ([application respondsToSelector:@selector(registerForRemoteNotifications)]) {
|
||||
[application registerForRemoteNotifications];
|
||||
if ([UIApplication instancesRespondToSelector:@selector(registerForRemoteNotifications)]) {
|
||||
[[UIApplication sharedApplication] registerForRemoteNotifications];
|
||||
}
|
||||
}
|
||||
|
||||
+ (void)application:(__unused UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
|
||||
+ (void)didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
|
||||
{
|
||||
NSMutableString *hexString = [NSMutableString string];
|
||||
NSUInteger deviceTokenLength = deviceToken.length;
|
||||
|
@ -94,7 +94,7 @@ RCT_EXPORT_MODULE()
|
|||
userInfo:userInfo];
|
||||
}
|
||||
|
||||
+ (void)application:(__unused UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)notification
|
||||
+ (void)didReceiveRemoteNotification:(NSDictionary *)notification
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:RCTRemoteNotificationReceived
|
||||
object:self
|
||||
|
|
Loading…
Reference in New Issue