From d29531c8904dde1e2739ab1a8e8d6d943078f403 Mon Sep 17 00:00:00 2001 From: Daniel Dimitrov Date: Wed, 26 Aug 2020 14:23:07 +0200 Subject: [PATCH] Temp fix: undelivered background data message ios MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This should be viewed as a temporary fix. A lot of people are reporting that the background data messages on iOS are not being delivered. The app wakes up, but the background listener doesn’t receive the message. Some apps that have a lot of JS apparently need more than the 2s timeout to be ready. So what happens is - app is started, 2s elapse, RNFBMessaging sends the message to the js handler, but the JS handler is not ready yet and misses the message. We mitigate this by delaying the delivery of the message to the JS side. This solution however is not optimal becasue we are sending a completionHandler after about 25s which means that our JS code would have only 16 to do something with the data message. A correct fix would be to figure out how to dispatch the message once the JS side is actually ready. https://github.com/invertase/react-native-firebase/issues/4104 --- .../messaging/ios/RNFBMessaging/RNFBMessaging+AppDelegate.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/messaging/ios/RNFBMessaging/RNFBMessaging+AppDelegate.m b/packages/messaging/ios/RNFBMessaging/RNFBMessaging+AppDelegate.m index 4b36340b80..22b2c38bd3 100644 --- a/packages/messaging/ios/RNFBMessaging/RNFBMessaging+AppDelegate.m +++ b/packages/messaging/ios/RNFBMessaging/RNFBMessaging+AppDelegate.m @@ -119,7 +119,7 @@ - (void)application:(UIApplication *)application didReceiveRemoteNotification:(N // TODO investigate later - RN bridge gets invalidated at start when in background and a new bridge created - losing all events // TODO so we just delay sending the event for a few seconds as a workaround // TODO most likely Remote Debugging causing bridge to be invalidated - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t) (2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t) (8 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [[RNFBRCTEventEmitter shared] sendEventWithName:@"messaging_message_received_background" body:[RNFBMessagingSerializer remoteMessageUserInfoToDict:userInfo]]; }); } else {