diff --git a/ios/RNFIRMessaging.m b/ios/RNFIRMessaging.m index 2b228aee91449a67ec295878488c4f3ea6deb37e..f65947ffb88bece894673127d6f4666533a3ae71 100644 --- a/ios/RNFIRMessaging.m +++ b/ios/RNFIRMessaging.m @@ -313,7 +313,9 @@ RCT_EXPORT_MODULE(); } -(void) addListener:(NSString *)eventName { + if([super respondsToSelector:@selector(addListener:)]){ [super addListener:eventName]; + } if([eventName isEqualToString:FCMNotificationReceived] && initialNotificationActionResponse) { [[NSNotificationCenter defaultCenter] postNotificationName:FCMNotificationReceived object:self userInfo:[initialNotificationActionResponse copy]]; @@ -332,16 +334,22 @@ RCT_EXPORT_METHOD(isDirectChannelEstablished:(RCTPromiseResolveBlock)resolve rej RCT_EXPORT_METHOD(getInitialNotification:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) { - UILocalNotification *localUserInfo = self.bridge.launchOptions[UIApplicationLaunchOptionsLocalNotificationKey]; - if (localUserInfo) { - resolve([[localUserInfo userInfo] copy]); - } else { - resolve([self.bridge.launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey] copy]); - } + NSDictionary* initialNotif; + NSDictionary *localUserInfo = [[self.bridge.launchOptions[UIApplicationLaunchOptionsLocalNotificationKey] userInfo] mutableCopy]; + NSDictionary *remoteUserInfo = [self.bridge.launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey] mutableCopy]; + if(localUserInfo){ + initialNotif = localUserInfo; + } else if (remoteUserInfo) { + initialNotif = remoteUserInfo; + } + if (initialNotif) { + [initialNotif setValue:@YES forKey:@"opened_from_tray"]; + resolve(initialNotif); + } else { + resolve(nil); + } } - - RCT_EXPORT_METHOD(getAPNSToken:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) { NSData * deviceToken = [FIRMessaging messaging].APNSToken;