From 799ce36d3743b59e0ecd02f850109bd5dd10b666 Mon Sep 17 00:00:00 2001 From: Rafael Matsunaga Date: Mon, 30 Mar 2020 16:09:02 -0300 Subject: [PATCH] [firebase_messaging] Fix both onMessage and onLaunch being called on iOS Fixes #1911 userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler: gets called even when the notification is opened with the app not running, so onResume was being fired when only onLaunch should be called. The fix adds a check for a non-null _launchNotification to prevent the invocation of onResume. --- .../firebase_messaging/ios/Classes/FLTFirebaseMessagingPlugin.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/firebase_messaging/ios/Classes/FLTFirebaseMessagingPlugin.m b/packages/firebase_messaging/ios/Classes/FLTFirebaseMessagingPlugin.m index b6a33a73d9dd..25fdb3ed5a8b 100644 --- a/packages/firebase_messaging/ios/Classes/FLTFirebaseMessagingPlugin.m +++ b/packages/firebase_messaging/ios/Classes/FLTFirebaseMessagingPlugin.m @@ -217,7 +217,7 @@ - (void)userNotificationCenter:(UNUserNotificationCenter *)center withCompletionHandler:(void (^)(void))completionHandler NS_AVAILABLE_IOS(10.0) { NSDictionary *userInfo = response.notification.request.content.userInfo; // Check to key to ensure we only handle messages from Firebase - if (userInfo[kGCMMessageIDKey]) { + if (userInfo[kGCMMessageIDKey] && _launchNotification == nil) { [_channel invokeMethod:@"onResume" arguments:userInfo]; completionHandler(); }