From aa7625ce391522c146f2c34fdbc8650238edbf51 Mon Sep 17 00:00:00 2001 From: Doron Pearl Date: Sun, 9 Dec 2018 16:50:59 +0200 Subject: [PATCH] fix background PN is received as foreground for the first time. refs #268 The `didReceiveRemoteNotification` checks for the current app state which will be active and hence wrongly emit the notification to JS as foreground. However at the exact time when the user opened the notification, the app was at the background hence this is a background notification by definition. In other words, conceptually determining if the notification is background or foreground should NOT be based on the time it was consumed from the queue but on the time it was received. Practically, if it was queued, then the app must have been in the background ==> background notification. --- RNNotifications/RNNotifications.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RNNotifications/RNNotifications.m b/RNNotifications/RNNotifications.m index 838fb0e..844d8e2 100644 --- a/RNNotifications/RNNotifications.m +++ b/RNNotifications/RNNotifications.m @@ -576,7 +576,7 @@ RCT_EXPORT_METHOD(consumeBackgroundQueue) // Push background notifications to JS [[RNNotificationsBridgeQueue sharedInstance] consumeNotificationsQueue:^(NSDictionary* notification) { - [RNNotifications didReceiveRemoteNotification:notification]; + [RNNotifications didReceiveNotificationOnBackgroundState:notification]; }]; // Push opened local notifications -- 2.26.2