-
Notifications
You must be signed in to change notification settings - Fork 4k
[firebase_messaging] onMessage is not fired for DATA message when app is in background - Android #2111
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
@iapicca cases are not the same. Issue that you linked is about onBackgroundMessage callback while mine is about onMessage. |
This issue still persists Channel stable, v1.12.13+hotfix.8 |
For data only, you need to set the message priority to "high" for android & set "content-available" for iOS, otherwise the devices class these as unimportant and ignore them if the app is in the background. |
@Ehesp I tried your suggestion but now I'm getting triggered twice on "onMessage" per push notification like #1911 here's my config: {
"token": [token],
"notification": {
"title": [title],
"body": [body],
},
"data": {
"some_data": [data]
},
"android": {
"notification": {
"sound": "default"
},
},
"apns": {
"headers": {
"apns-priority": 5,
},
"payload": {
"aps": {
"content-available": 1,
},
},
},
} |
I can also confirm that this is not working with I'm using the following setup:
If the app is in the foreground |
I solved this issue |
Closing in favour of trying the latest messaging version which has been been heavily reworked, along with documentation, since this issue was raised: https://firebase.flutter.dev/docs/messaging/overviewIf 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
I've set up firebase_messaging and I'm able to receive messages from FCM in general. All the callbacks work just fine both on Android and iOS except onMessage when app is in background state.
Message I'm sending (through postman):
Message is received when app is in foreground, but not when in background.
(Also funny fact - when in foreground this message is received as {notification: {title: null, body: null}, data: ...., but maybe its just how FCM sends these types of messages - with title and body present but set to null)
I've tried different versions of firebase_messaging package, 6.0.12 included.
Also worth mentioning that background messages (onBackgroundMessage ones, but as far as I understand that is not the same as onMessage callback in background state) work well if configured. I've tested with and without that config.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Application receives message from FCM
Flutter doctor
[√] Flutter (Channel dev, v1.15.3, on Microsoft Windows [Version 10.0.18363.657], locale en-US)
• Flutter version 1.15.3 at C:\flutter
• Framework revision 67826bdce5 (3 weeks ago), 2020-02-10 14:59:32 -0800
• Engine revision 6158f03ef5
• Dart version 2.8.0 (build 2.8.0-dev.8.0 514a8d4c84)
[√] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
• Android SDK at C:\Users\admin\AppData\Local\Android\sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-29, build-tools 28.0.3
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)
• All Android licenses accepted.
[√] Android Studio (version 3.5)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin version 42.1.1
• Dart plugin version 191.8593
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)
[√] VS Code (version 1.42.1)
• VS Code at C:\Users\amunk\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.8.1
[√] Connected device (1 available)
• AOSP on IA Emulator • emulator-5554 • android-x86 • Android 9 (API 28) (emulator)
• No issues found!
The text was updated successfully, but these errors were encountered: