-
Notifications
You must be signed in to change notification settings - Fork 4k
🐛 [firebase_messaging] Silent Notifications not working on iOS if app is terminated #9300
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 @russellwheatley maybe you have more of a clue than me on that? |
I can add more details. After upgrading to 12.0.1 from 11.4.1, silent notifications on iOS work also when app is killed. Setup is: Video below: IMG_1483.MOV |
Hello @darshankawar, any idea about this? |
Its simply not ok. It seems like silent push is not working at all. They arrives when opening the app |
@iosephmagno |
Hello @darshankawar Basically, in above video we kill our app and start sending messages to demonstrate that we do receive and show incoming silent notifications when app is terminated. But at some point we open another app (Rest app) and this causes our terminated app not being able to show incoming silent notifications anymore. This is why we think it might be a bug of firebase_messaging. Can you please try to reproduce the issue on your side? Here is our setup: firebase_messaging: 12.0.1 Notification Sample Payload: ios/runner/AppDelegate.swift import UIKit ios/runner/Info.plist <key*>FirebaseAppDelegateProxyEnabled</key*> |
@darshankawar @russellwheatley we did other tests today. Pretty sure we discovered a pesky bug. It is pesky because it can go unnoticed during a test. In fact, if you close app and send some silent notifications, they will be shown as expected. Unfortunately, they stop showing as soon as user opens different apps on the device. We think some conflicts arise and onBackgroundMessage is not longer triggered. |
I thought it best to also add a Feature Request #9317. |
Thanks for the update @iosephmagno RPReplay-Final1660045282.MP4 |
Hello @darshankawar, what PR are you referring to? As for your test, I see you are using firebase console to send notifications to your device. This means that maybe you are using “notification” in the payload, not “data-only” silent notifications. Can you double check it? As mentioned, we have no issues with receiving notifications if we use “notification”. But in that case, we cannot modify payload (eg. decrypt body field) before displaying badge. This is why we asked for the new feature described in #9317. To recap: remote notifications work in all app states and always arrive with highest priority. They are the standard for sending sensitive high priority notifications. However, with this type of notification, there is currently no way to modify content before displaying head ups on iOS. To do that, firebase_messaging should support mutable-content and Service App Extension #9317 |
I am referring to #9292 in which you also commented asking if example app is affected by your use case.
I also tried with data-only message as below:
With which it was received properly. The console log shows below:
After terminating app and then sending data-only message:
Below is the video showing the same. You may not see anything happening in UI (except, the device vibrates after receiving data-only message) but the corresponding events are triggered as shown in console. RPReplay-Final1660117547.MP4I suggest you to try the updated example app changes pushed yesterday to see silent notifications working properly on iOS. |
Thanks for the kind assistance! Which iOS version are you using? Because I already looked at the PR example and there is no difference with our code. Also, Apple confirmed we must use “notification” with “content-mutable” and a service app extention to bypass above restrictions for “data” notifications: They also said that, contrary to android, iOS silent notifications might be put on hold temporarily if traffic is huge, and hence are not to be used for instant messaging or apps which send encrypted data with high priority. In that case the solution on iOS is to use mutable-content and service app notifications. Mutable-content tells that notification must not be displayed untill content is passed to the service app notifications (which usually modify content by performing a body-field decryption). This is in the majority of cases the reason why developers want to modify notification content before head up is displayed. Sample payload: |
For a full coverage of iOS notifications, firebase-mesaging should add support for mutable-content in notification payload and let developers modify notification’s fields before they show head ups through flutter_local_notification, just as we now do with data-only notifications. |
I am on iOS 15.3.1.
Yes, added as below:
And then triggered the push event through
The log didn't print because it didn't record when app was terminated. |
IOS version is old. Can you use flutter local notifcation to show head up in your video? Idk what to say, when (app is terminated AND not the last opened one) it doesnt work for us and our code is the same of Russell’s example. Also, it is expected that it doesnt work in such case, because it is Apple restriction. @russellwheatley can you please look into this and shed some light? |
Keeping it open and labeling for further insights from the team. /cc @russellwheatley |
Hello,
|
@scalz yes Apple confirmed that silent notifications are not meant to be used like on android. To send high priority notifications, iOS requires “notification” and “mutable-content:1”. Firebase messaging should integrate a service app extention to let us modify content before displaying the head up. I think they are investigating this already. |
This comment was marked as off-topic.
This comment was marked as off-topic.
@m2sahin Please check github's code of conduct. |
So, when will this be resolved? |
i have good news it works in the native side there are bug with firebase_messageing package |
@hatemragab 👏 Can you share your discovery in #9536 ? |
Hello everyone, we’ve reviewed the issues opened for iOS background messages and we want to make our position clear. Android and iOS handle background messaging differently. The decision made by the iOS operating system whether messages reaches the relevant iOS event handler (and subsequently received by the Dart background messaging handler) is based on a number of criteria, such as: CPU usage, priority level (data-only messages are considered “low priority” by iOS, android does not), battery level, amount of messages being received by the app, background/terminated application state, etc. This is a fundamental difference between the platforms, and you need to be aware of them when designing your application. One solution suggested for iOS data-only messages unreliability has been to add a NotificationExtension. But this will still not create parity with Android as you will still have to include a notification with your message (therefore not data-only). It will still render the original notification if you do not update/mutate the notification that comes through the system in a timely manner. We are not currently considering this as a solution due to these limitations. We also will not support non-FCM messages from third party packages. We specifically only support messages received from the Firebase APIs since we cannot guarantee that messages received from third party packages will not have any unintended side-effects on other Firebase products such as messaging delivery reporting and Analytics data. To help us triage and locate genuine issues that need to be addressed we have created a specific issue template for iOS background messages. If you believe you still have an issue that needs to be addressed, please create a new issue following this template. I will be closing this issue in favor of raising a new issue with the new template above. This template will help you provide us with all the information we need to investigate a potential issue with background messaging on iOS. |
Hello,
We already discussed silent notifications on ios in foreground and background mode and I shared our working solution in #8277.
Now above thread is closed, so I’m forced to open this other one.
Situation is:
Android: silent notifications work in all scenarios: app in foreground, background and killed.
ios: silent notifications work in foreground and background mode, but dont work when app is killed IF app is not the last one opened.
The text was updated successfully, but these errors were encountered: