[ReactNative] pass in launchOptions to relevant bridged modules

This commit is contained in:
Kevin Gozali 2015-04-30 14:09:55 -07:00
parent 63ab6e8281
commit 824da1bada
2 changed files with 6 additions and 8 deletions

View File

@ -13,8 +13,6 @@
@interface RCTPushNotificationManager : NSObject <RCTBridgeModule>
- (instancetype)initWithInitialNotification:(NSDictionary *)initialNotification NS_DESIGNATED_INITIALIZER;
+ (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings;
+ (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)notification;

View File

@ -24,14 +24,8 @@ RCT_EXPORT_MODULE()
@synthesize bridge = _bridge;
- (instancetype)init
{
return [self initWithInitialNotification:nil];
}
- (instancetype)initWithInitialNotification:(NSDictionary *)initialNotification
{
if ((self = [super init])) {
_initialNotification = [initialNotification copy];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(handleRemoteNotificationReceived:)
name:RCTRemoteNotificationReceived
@ -45,6 +39,12 @@ RCT_EXPORT_MODULE()
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
- (void)setBridge:(RCTBridge *)bridge
{
_bridge = bridge;
_initialNotification = [bridge.launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey] copy];
}
+ (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
{
if ([application respondsToSelector:@selector(registerForRemoteNotifications)]) {