From f8aa45b094583e4f37a4a480971511da325298e0 Mon Sep 17 00:00:00 2001 From: Libin Lu Date: Fri, 7 Oct 2016 15:33:58 -0400 Subject: [PATCH] add show_in_foreground option --- android/react-native-fcm.iml | 22 +++++++++---------- .../react/fcm/FIRLocalMessagingHelper.java | 4 +++- .../xcschemes/xcschememanagement.plist | 2 +- ios/RNFIRMesssaging.m | 11 +++++++--- 4 files changed, 23 insertions(+), 16 deletions(-) diff --git a/android/react-native-fcm.iml b/android/react-native-fcm.iml index be7ba28..02e9551 100644 --- a/android/react-native-fcm.iml +++ b/android/react-native-fcm.iml @@ -65,14 +65,6 @@ - - - - - - - - @@ -81,6 +73,14 @@ + + + + + + + + @@ -99,7 +99,7 @@ - + @@ -110,14 +110,14 @@ - + - + diff --git a/android/src/main/java/com/evollu/react/fcm/FIRLocalMessagingHelper.java b/android/src/main/java/com/evollu/react/fcm/FIRLocalMessagingHelper.java index b818b13..ec47475 100644 --- a/android/src/main/java/com/evollu/react/fcm/FIRLocalMessagingHelper.java +++ b/android/src/main/java/com/evollu/react/fcm/FIRLocalMessagingHelper.java @@ -160,7 +160,9 @@ public class FIRLocalMessagingHelper { Intent i = new Intent("com.evollu.react.fcm.ReceiveLocalNotification"); i.putExtras(bundle); mContext.sendOrderedBroadcast(i, null); - }else{ + } + + if(!mIsForeground || bundle.getBoolean("show_in_foreground")){ Intent intent = new Intent(mContext, intentClass); intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); intent.putExtras(bundle); diff --git a/ios/RNFIRMessaging.xcodeproj/xcuserdata/LLu.xcuserdatad/xcschemes/xcschememanagement.plist b/ios/RNFIRMessaging.xcodeproj/xcuserdata/LLu.xcuserdatad/xcschemes/xcschememanagement.plist index 54a603d..a3337cb 100644 --- a/ios/RNFIRMessaging.xcodeproj/xcuserdata/LLu.xcuserdatad/xcschemes/xcschememanagement.plist +++ b/ios/RNFIRMessaging.xcodeproj/xcuserdata/LLu.xcuserdatad/xcschemes/xcschememanagement.plist @@ -7,7 +7,7 @@ RNFIRMessaging.xcscheme orderHint - 7 + 9 SuppressBuildableAutocreation diff --git a/ios/RNFIRMesssaging.m b/ios/RNFIRMesssaging.m index 68c2ca8..05ce587 100644 --- a/ios/RNFIRMesssaging.m +++ b/ios/RNFIRMesssaging.m @@ -276,9 +276,14 @@ RCT_EXPORT_METHOD(getBadgeNumber: (RCTPromiseResolveBlock)resolve rejecter:(RCTP - (void)handleNotificationReceived:(NSNotification *)notification { - NSMutableDictionary *data = [[NSMutableDictionary alloc]initWithDictionary: notification.userInfo]; - [data setValue:@(RCTSharedApplication().applicationState == UIApplicationStateInactive) forKey:@"opened_from_tray"]; - [_bridge.eventDispatcher sendDeviceEventWithName:FCMNotificationReceived body:data]; + if([notification.userInfo valueForKey:@"opened_from_tray"] == nil){ + NSMutableDictionary *data = [[NSMutableDictionary alloc]initWithDictionary: notification.userInfo]; + [data setValue:@(RCTSharedApplication().applicationState == UIApplicationStateInactive) forKey:@"opened_from_tray"]; + [_bridge.eventDispatcher sendDeviceEventWithName:FCMNotificationReceived body:data]; + }else{ + [_bridge.eventDispatcher sendDeviceEventWithName:FCMNotificationReceived body:notification.userInfo]; + } + } @end -- 2.26.2