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:
Michelle Todd 2016-01-05 02:42:18 -08:00 committed by facebook-github-bot-4
parent ee82bad3f7
commit 1dc5dca604
3 changed files with 16 additions and 11 deletions

View File

@ -39,15 +39,20 @@ var NOTIF_REGISTER_EVENT = 'remoteNotificationsRegistered';
* And then in your AppDelegate implementation add the following: * 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 * - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
* { * {
* [RCTPushNotificationManager application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken]; * [RCTPushNotificationManager didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
* } * }
* // Required for the notification event. * // Required for the notification event.
* - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)notification * - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)notification
* { * {
* [RCTPushNotificationManager application:application didReceiveRemoteNotification:notification]; * [RCTPushNotificationManager didReceiveRemoteNotification:notification];
* } * }
* ``` * ```
*/ */

View File

@ -13,8 +13,8 @@
@interface RCTPushNotificationManager : NSObject <RCTBridgeModule> @interface RCTPushNotificationManager : NSObject <RCTBridgeModule>
+ (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings; + (void)didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings;
+ (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken; + (void)didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken;
+ (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)notification; + (void)didReceiveRemoteNotification:(NSDictionary *)notification;
@end @end

View File

@ -71,14 +71,14 @@ RCT_EXPORT_MODULE()
return @{@"initialNotification": RCTNullIfNil(initialNotification)}; return @{@"initialNotification": RCTNullIfNil(initialNotification)};
} }
+ (void)application:(__unused UIApplication *)application didRegisterUserNotificationSettings:(__unused UIUserNotificationSettings *)notificationSettings + (void)didRegisterUserNotificationSettings:(__unused UIUserNotificationSettings *)notificationSettings
{ {
if ([application respondsToSelector:@selector(registerForRemoteNotifications)]) { if ([UIApplication instancesRespondToSelector:@selector(registerForRemoteNotifications)]) {
[application registerForRemoteNotifications]; [[UIApplication sharedApplication] registerForRemoteNotifications];
} }
} }
+ (void)application:(__unused UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken + (void)didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{ {
NSMutableString *hexString = [NSMutableString string]; NSMutableString *hexString = [NSMutableString string];
NSUInteger deviceTokenLength = deviceToken.length; NSUInteger deviceTokenLength = deviceToken.length;
@ -94,7 +94,7 @@ RCT_EXPORT_MODULE()
userInfo:userInfo]; userInfo:userInfo];
} }
+ (void)application:(__unused UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)notification + (void)didReceiveRemoteNotification:(NSDictionary *)notification
{ {
[[NSNotificationCenter defaultCenter] postNotificationName:RCTRemoteNotificationReceived [[NSNotificationCenter defaultCenter] postNotificationName:RCTRemoteNotificationReceived
object:self object:self