-
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]: Silent notification not working on iOS, but works on Android in version firebase_messaging: ^15.1.3 #13476
Comments
Hi @dhara6894 , thanks for the report. I'm currently looking into this. |
I was able to reproduce this issue on iOS 18. Additionally, when I send a test message from the Firebase console, it doesn’t arrive on my device. Could you check if you're seeing the same behavior on your end? Also, which version of iOS are you encountering this issue on? Reproduced with |
Perhaps this issue is related to #13442 |
@SelaseKay I have iOS version 17.6.1 on my device, and I am encountering this issue. |
Thanks. Have you tried firing a test message from your Firebase console? |
@SelaseKay I have tried sending messages from my app's backend, and although the backend sends a silent notification, I observed that none of the methods are called. |
@SelaseKay, I am experiencing the same issue. I have also tried using Postman. While normal push notifications are functioning properly, silent notifications are not working Tried the following payloads: {
"message": {
"token": "{{deviceFCMToken}}",
"data": {
"click_action": "FLUTTER_NOTIFICATION_CLICK"
}
}
} and {
"message": {
"token": "{{deviceFCMToken}}",
"data": {
"click_action": "FLUTTER_NOTIFICATION_CLICK"
},
"apns": {
"headers": {
"apns-priority": "5"
},
"payload": {
"aps": {
"content-available": 1
}
}
}
}
} |
@SelaseKay Have you found anything related to the issue? Let me know if you need further details from me. |
We have recently experienced an issue within our apps where silent notifications (data-only) weren't triggering the onMessage nor onBackgroundMessage callbacks on iOS (Android was working fine). We were using:
Non-silent notifications were working as expected, and we could even receive test notifications sent from the Firebase console. After some debugging, we identified the notification was reaching the device (#8277 (comment)), but the firebase_messaging plugin wasn't handling it for some reason. After testing disabling method swizzling and handling messages manually without any success, as suggested in some comments in the linked issue, we finally ended up with the following workaround: We only needed to add the following code to our AppDelegate.swift (with method swizzling enabled by default): override func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
super.application(application, didReceiveRemoteNotification: userInfo, fetchCompletionHandler: completionHandler)
} No other didReceiveRemoteNotification method implementation worked for us, just calling Looking for recent changes in the firebase_messaging package that could be related to this issue, we found this commit dropped a default implementation for the deprecated didReceiveRemoteNotification method. Unfortunately, we didn't have the time to test if it's indeed related. |
We're encountering the same issue with data messages (silent notifications) on iOS in version The workaround from @areynolds8787 didn't work for us. |
We're encountering the same issue with data messages (silent notifications) on iOS in version 15.1.3 |
areynolds8787 workaround works for me
|
I'm also having this issue. Notifications are working fine on Android but not on IOS. I tried testing it also from console Firebase Messaging -> Send Test Message but still no success. |
@areynolds8787 workaround works for me |
Hey @dhara6894, I have a fix for background message handling in iOS that should allow you to turn Could you try this branch: #13525, and let me know if it works for you? Thanks 🙏 |
Hey @russellwheatley! Thanks for the fix. I can confirm data-only notifications are working without having to apply any workaround using the linked branch. Just to clarify, we had to keep FirebaseAppDelegateProxyEnabled true by default to make our workaround work, so we just removed the |
Is this fix work for macOS? |
Is there an existing issue for this?
Which plugins are affected?
Messaging
Which platforms are affected?
iOS
Description
There is an issue where silent notifications are not working on iOS devices, while they function correctly on Android. The expected behavior is for silent notifications to work consistently across both platforms.
Reproducing the issue
Firebase Core version
3.6.0
Flutter Version
3.24.3
Relevant Log Output
While checking the logs for the silent notification issue on iOS, it was observed that neither onBackgroundMessage nor onMessage methods are being triggered. This issue is specific to iOS, as the silent notifications work fine on Android, and both methods get called as expected.
Flutter dependencies
Expand
Flutter dependencies
snippetAdditional context and comments
Silent notifications were working correctly with the following package versions:
firebase_core: ^2.27.0
firebase_messaging: ^14.7.19
However, after updating to:
firebase_core: ^3.6.0
firebase_messaging: ^15.1.3
Silent notifications stopped working on iOS. Neither the onBackgroundMessage nor onMessage methods are triggered, while everything works fine on Android.
Steps to reproduce:
Use firebase_core: ^2.27.0 and firebase_messaging: ^14.7.19, send a silent notification, and observe that it works on both iOS and Android.
Update to firebase_core: ^3.6.0 and firebase_messaging: ^15.1.3.
Send a silent notification again and observe that it no longer works on iOS (but still works on Android).
Expected outcome: Silent notifications should continue to work after the package update, with both onBackgroundMessage and onMessage being triggered on iOS.
The text was updated successfully, but these errors were encountered: