-
Notifications
You must be signed in to change notification settings - Fork 4k
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
[firebase_messaging] onMessage/onResume is called twice on Android/iOS #1669
Comments
Facing same issue. onResume and onLaunch works fine but onMessage triggers twice. |
Facing same issue.! |
Facing the same problem with onMessage and onResume. |
Same issue here, its is boring, in other app with other version the bug dont occurs T_T |
I confirm (firebase messaging 6.0.9, and flutter 1.12.13+hotfix.5) |
Only on the android, it seems to me. Its easy to handle programmatically but not sure if there's a clean way to deal with it. |
Facing same issue. |
I confirm it's only on Android |
onResume is also called twice |
Here the same issue, I get duplicate notifications on android (onResume and OnMessage). Here you will find all my details. It is the default flutter project with firebase firebase_messaging: ^6.0.9 Output: |
same issue on iOS. onMessage called twice with different message ID, so there could be the issue on server side. |
Same here, on Message is called twice, flutter team are you listening? |
@janosdupai I don't have this issue on iOS. I tested again today |
@woprandi I try to trigger a push notification with php code. It give me a success: 1 result, but on my device I always receive 2 message with the same title&body but different message ID (which is provided by google firebase). I double checked, that I trigger this function only once on a server side. my code on the server
I tried to trigger this from Terminal, which worked fine, and sent only 1 message. My terminal code: DATA='{"notification": {"body": "this is a body","title": "this is a title"}, "priority": "high", "data": {"click_action": "FLUTTER_NOTIFICATION_CLICK", "id": "1", "status": "done"}, "to": "MYDEVICETOKEN"}' |
@janosdupai Can you check the FCM response via |
{"multicast_id":8502274311835153380,"success":1,"failure":0,"canonical_ids":0,"results":[{"message_id":"1579683773320267"}]} I receive this message_id in flutter app, but I receive another one in a small delay (with same message title and body).... on flutter console flutter: {status: done, id: 1, click_action: FLUTTER_NOTIFICATION_CLICK, google.c.a.e: 1, gcm.message_id: 1579683773320267, aps: {alert: {title: This is title #1, body: here is a message. message}, sound: default}} |
I'm test used terminal but the result it's same. onMessage is called twice. I'm testing on Android device. |
I receive it two times even from terminal |
Facing same issue with firebase_messaging: ^6.0.9. onMessage and onResume called multiple times |
Can you imagine how many issues there are under this package? You need to be more appreciative of their craft bro. They can't solve everything overnight, give them some time. |
After fast investigation, the method |
A working workaround :
|
For me, works on update Flutter version 1.17.5 and firebase_messaging: ^6.0.16 |
I'm facing the same issue on iOS |
Still facing the same issue on both Android and iOS. I'm using |
I think I solved the issue.But I need to be sure as to what steps you are following.Those who have the issue please reply to this comment with the steps by step procedure... |
Flutter doctor
Can you share your solution? |
I've noticed that the callback onMessage got called twice in FLTFirebaseMessagingPlugin.m commenting out
did the trick. The flow is:
|
I tried @fnicastri's workaround and it works for onMessage, but onResume is still called twice on iOS. onResume is called when the app is still in the background as well as when the app is brought to the foreground. Is it supposed to be this way? From reading the documentation, I thought onResume will only be called when the app is brought to the foreground, and not when it's in the background too. |
@rivetingpeppermint @TahaTesser |
I also just found out that when I run my app on iOS, onResume and onLaunch are called when we open the app normally (from the home screen, not from clicking the notification in the system tray). This behavior doesn't happen with Android. I used the iPad Pro (9.7-inch, running iOS 13.5.1) and iPhone 7 (running iOS 12.4.1). |
@TahaTesser |
it on iOS too |
Does anyone have a workaround for this problem yet? |
init firebase only once, it worked for me |
Can you explain it? |
It's fixed with the new version. I'm using this current configuration: (Don't use carets it's not good)
Be aware there is now some additional Android setup 👎 |
@OllyDixon what additional setup? |
@rivetingpeppermint ahh sorry, it's on the github/pub page. |
It's not. if #available(iOS 10.0, *) {
UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate
} I get nothing at all. Using the example I get onMessage twice and onResume once. |
firebase_core: 0.5.0 I am getting same issue at iOS. |
Having the same issue on IOS for onMessage and onResume.
|
Same issue here, using flutter v. 1.22.0 and firebase messaging 7.0.3, this behavior happens when I use |
@salva73 |
Describe the bug
The
onMessage
callback is always called twiceTo Reproduce
Steps to reproduce the behavior:
print
statement in theonMessage
callbackExpected behavior
Only one print on the console
Additional context
I don' t have the same issue with
onBackgroundMessage
. It's called once as expectedThe text was updated successfully, but these errors were encountered: