-
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] flutter app cannot receive notification with data only on IOS #8914
Comments
Hi @victorkwok97, Thanks for filing the issue. Using the same backend are the notifications received on Android device? Additionally can you test if sending notifications from terminal works?
sample payload.json {
"aps": {
"alert": {
"title": "Game Request",
"subtitle": "Five Card Draw",
"body": "Bob wants to play poker"
}
}
} This will help us figure out whether the issue is in the app configuration or the backend. Also ensure that you have approved notification permissions on ios. |
This issue is a continuation of closed and locked issue #8548 (with @victorkwok97 comment) which superseded #8378 and is specifically about data only notifications (the Apple terminology is silent). @maheshmnj please use a silent notification such as this sample from Apple's documentation Pushing Background Updates to Your App {
"aps" : {
"content-available" : 1
},
"acme1" : "bar",
"acme2" : 42
} For us data notifications always work for Android. We do receive notifications on iOS (i.e. setup is correct) when we use any user facing notifications: |
@maheshmnj For iOS, I have tried sending the notification from terminal, it works. Further, I have also tried sending the notification from the Firebase console as well. So I can ensure you that the configuration is fine. The issue, as elaborated by @rich-j , is that it only does not work for the silent notifications. So for those cases only the data field is set. |
Hello @victorkwok97, /**
* On iOS, use this field to represent `content-available` in the APNs payload.
* When a notification or data message is sent and this is set to `true`, an
* inactive client app is awoken. On Android, data messages wake the app by
* default. On Chrome, this flag is currently not supported.
*
* **Default value:** `false`
*/
contentAvailable?: boolean; await admin.messaging().sendToDevice(
tokens,
{
data: {
...
},
},
{ contentAvailable: true }
); Not sure if the casing changes something? |
@Lyokone I believe you are conflating an API with the JSON message. We use the Firebase Java API which has an /**
* Specifies whether to configure a background update notification.
*
* @param contentAvailable True to perform a background update.
* @return This builder.
*/
public Builder setContentAvailable(boolean contentAvailable) {
this.contentAvailable = contentAvailable;
return this;
} But the code that builds the JSON message changes the API name and value to: if (builder.contentAvailable) {
fields.put("content-available", 1);
} This field is then added to the JSON message with the name and value matching the Apple documentation. |
Oh okay, maybe I didn't understood properly. @victorkwok97 sample in the original message is using node.js. |
Thanks for the clarification, I am able to reproduce the issue user facing notifications work but silent notifications do not. sending this payload works {
"aps": {
"alert": {
"title": "Game Request",
"subtitle": "Five Card Draw",
"body": "Bob wants to play poker"
},
"content-available" : 1
}
} while this doesn't {
"aps" : {
"content-available" : 1
},
"acme1" : "bar",
"acme2" : 42
} I do have background Notifications and remote notifications capabilities enabled in xcode. flutter doctor -v (mac)
|
@victorkwok97 @rich-j The original issue seems to be #8277 and looking at below comments from that issue, it seem to be working: #8277 (comment) Can you try the same and see if above helps in your case ? |
@darshankawar I have tried all of them but sadly none of the solutions of those comments worked. for #8277 (comment) , you can see that I am using "content_available" already from my example above. So it should be correct. As an extra information, the device that I use for testing runs on iOS 14.8.1. I have tried on a iOS 15.5 simulator as well. Both of them didn't work. |
/cc @russellwheatley . Similar / related issue for your reference: #8277 |
This works. Follow this link for example payloads. Make sure you have manual setup instead of dart initialisation (i.e. |
I am closing this out as this issue was confirmed as resolved by me and users in this issue. Will reopen if you have a reproducible sample/repo. Thanks. |
@russellwheatley I will confirm that using manual installation instead of dart initialization makes the problem disappear. So if you're not considering this a code "bug" then it should be treated as a documentation issue. The documentation explicitly states
We followed the current documentation and FCM did not work in this case. |
Bug report
Describe the bug
When only the data field is set but not the notification field, the flutter app cannot receive the notification on iOS devices. It works on Android devices.
I am using version 11.4.1 firebase_messaging
Steps to reproduce
In node.js:
In flutter:
Expected behavior
The callback should be fired on iOS app as well.
Sample project
None
Additional context
None
Flutter doctor
Run
flutter doctor
and paste the output below:Click To Expand
Flutter dependencies
Run
flutter pub deps -- --style=compact
and paste the output below:Click To Expand
The text was updated successfully, but these errors were encountered: