From b03b51ac0a5f60d30bfdd953fc13266b658241c4 Mon Sep 17 00:00:00 2001 From: Libin Lu Date: Mon, 12 Feb 2018 15:50:26 -0500 Subject: [PATCH] add opened_from_tray in initialNotificaiton --- ios/RNFIRMessaging.m | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/ios/RNFIRMessaging.m b/ios/RNFIRMessaging.m index 2b228ae..573f002 100644 --- a/ios/RNFIRMessaging.m +++ b/ios/RNFIRMessaging.m @@ -332,16 +332,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; -- 2.26.2