-
Notifications
You must be signed in to change notification settings - Fork 4k
[firebase_messaging] Background Message Handler not called #1590
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 @mahmoud0123 |
Hi @iapicca thanks for your response here is flutter doctor
|
I have the same problem, and my setup is very similar. Just trying to print something in I can see the notification coming in and Android starting the app in logcat:
Here is my flutter doctor:
|
Similar thing happening to me (#1709), but it my case, the method is called as long as I don't reopen my app once it has been installed. That is, once the app is installed and launched for the first time, if I go ahead and close it, onBackgroundMessage will be called when I send a data message. But if I reopen the app, and then close it once again, it will no longer be called. |
This might be an issue related to flutter_local_notification package: |
Doesn't seem to be the case for me (I've checked just now). I have noticed something interesting though: The messages arrive just fine when the application is completely closed, but onBackgroundMessage won't trigger when the app is still running in the background. What I mentioned in #1709 applies to this new observation. I'll make myself a bit clearer:
|
I've made a pull request that solves the issue for me (#1774), can anyone else confirm? |
Yes, I can confirm that your change fixes the problem.
The message in point 6 was lost before your fix. |
How to use the last version? |
#First clone Eddy's repo: #Then point to this workspace, in pubspec.yaml: dependencies: firebase_messaging: |
I have tested it, onResume,On onLaunch is ok, but on background doesn't work. [✓] Flutter (Channel stable, v1.12.13+hotfix.5, on Mac OS X 10.14.6 18G2022, locale zh-Hans-US) [✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 11.3) [✓] Android Studio (version 3.5) [✓] Connected device (1 available) • No issues found! |
Awesome! I ran into exactly the same issue. Glad I came across your fix, much appreciated. |
@Jackcui68 this is just a shot in the dark, but maybe the issue is with how your device handles background processes? Check out this website: https://dontkillmyapp.com/ |
@Eddydpyl Does this solution only work for android or IOS as well...? |
@dazednconfusing it only fixes the issue in Android, and iOS can't process a data message when the app is not running, so it really isn't as useful. As far as I know, the onMessage callback is the one that should be triggered in iOS when receiving a data message, as long as the app is running. If it's not, the message should be queued to be received once the app is running. |
Hello. Any updates? for me call onBackgroundMessage does not work too. I am use for test real device with android 9 |
me too. if somebody gets something please |
Hello all. I realized what the problem is. For work onBackgroundMessage we must send notification only with param 'data' and without param notification. Php example code:
This notification do not show but onBackgroundMessage will work. If you want show notification and run onBackgroundMessage you must send 2 notification from server, first as example above and second as
|
I tried data but still doesn't work, this is my index.js
|
Try remove this |
But how will my notification be handled to the notification tray... for the user to get a notification. Please help |
If you need work background and show notification, you must send 2 notification, first with
and without data and second with data and without notification arrays |
Any news? I've tried with Notification message and Data Message but the onBackgroundMessage callback is not called when the app has been terminated |
Hello, Iam developing an app for pushing notifications from fcm, when the app in background or terminated and receive notification i need to save the data of this notification local in (sqlit), without click on the notification or re-open the app gain. the background message handler not called or read the message when the app in background. help please.
NotificationHandler.dart
The text was updated successfully, but these errors were encountered: