-
Notifications
You must be signed in to change notification settings - Fork 4k
[firebase_messaging] Both onMessage and onLaunch called with same gcm.message_id #1911
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi @RabbitKabong |
Yeah, when I did some initial investigation I saw #1669, too, but 2 things stick out to me:
I think this is a separate issue. |
It looks like the culprit is: - (void)userNotificationCenter:(UNUserNotificationCenter *)center
didReceiveNotificationResponse:(UNNotificationResponse *)response
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]) {
[_channel invokeMethod:@"onResume" arguments:userInfo];
completionHandler();
}
} Which gets called both when the app is in background (when we want to call "onResume") and when the app is not running at all. Checking if there's no _launchNotification pending seems to be enough to avoid the problem. if (userInfo[kGCMMessageIDKey] && _launchNotification == nil) {
[_channel invokeMethod:@"onResume" arguments:userInfo];
completionHandler();
} I'm adding a PR with the change. |
Fixes firebase#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.
…irebaseUser (#1911) * Sign-in methods now return `AuthResult` instead of `FirebaseUser`. * Change `reauthenticateWithCredential` to return AuthResult as well * Update tests
Closing in favour of trying the latest messaging version which has since this issue was created been heavily reworked to improve it along with detailed documentation: https://firebase.flutter.dev/docs/messaging/overview If you still have a problem please raise a new GitHub issue with up to date information and code snippets if possible. Thanks. |
Describe the bug
After sending a notification via google-api-php-client to GCM, I receive the same message twice on a device: both onMessage and onLaunch are triggered with the same gcm.message_id.
To Reproduce
Steps to reproduce the behavior:
onMessage
onLaunch
Expected behavior
With the app closed, I'd expect to see onLaunch processed by the app, and not onMessage.
Additional context
I'm using firebase_core ^0.4.3+1, firebase_messaging ^6.0.9, and firebase_analytics ^5.0.9 in my app at the moment.
I haven't been able to reproduce this issue in the iOS Simulator, Android simulator, or on an Android device. I haven't been able to reproduce this on several other iOS devices I have access to, either. Unsubscribing from notifications (via
unsubscribeFromTopic()
), reinstalling the app, and then resubscribing didn't make a difference.Not sure if it matters, but the two devices I can replicate this on were both recently upgraded and migrated from older iPhones.
Here's the code snippets I use to handle the notifications:
The text was updated successfully, but these errors were encountered: