Closed Gobmichet closed 7 months ago
@Gobmichet Can you try this and see if it helps in your case ? Also, can you provide the iOS device details you are using ?
Hi,
After several additionnal tests & researches here's what we can add to the "diagnosis" :
We test the flutter app on iOS physical device via testFlight in order to be able to test the background/terminated/reboot states and here's what we observe :
Indeed :
But AFTER the device REBOOT, everything is broken and no notifications are bg handled anymore until another notification received in foreground !
So the problem really seems to be the starting of that background handler !
saying that we did add this code found on the firebase site when creating an app :
And here is our code :
import UIKit
import Flutter
import FirebaseCore
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
FirebaseApp.configure()
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}
But no changes, still doesn't work :(
Can someone please help us to get that BG handler part to work on iOS since it already works like a charm on Android ???
Help would REALLY be appreciated ! ;)
PS : last tests stackTrace from macOS when receiving a notification... "CANCELED" ?
Thanks for the update. I am not sure what should be the expected behavior after rebooting the device, ideally, it should resume the actions as before, but wondering if in this case, the native ios comes into picture or not.
I'll keep the issue open and label for team's input.
Thanks in advance, we're really stuck in here and think we do have already tried everything possible :(
The system is blocking your notifications from appearing. This isn't a bug in firebase messaging. Try using data only messages. When you say reboot, do you mean switch iPhone off & on?
yes i do ;)
Notifications ALWAYS do appear on the phone "Just" the background peristance isn't triggered and ONLY on iPhone.
indeed the only way to have the background code to work is to first receive a notification in foreground (app opened) then it works UNTIL you reboot the iPhone.
After reboot nothing works anymore until a first notif is again received when app is opened.
Hey @Gobmichet. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 days I will close it automatically.
If you have more information that will help us get to the bottom of this, just add a comment!
Since there haven't been any recent updates here, I am going to close this issue.
@Gobmichet if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.
Is there an existing issue for this?
Are you aware of the differences between iOS and Android background message handling?
Do you have an active Apple Developer account?
Are you using a physical iOS device to test background messages?
Have you enabled "Remote Notifications" & "Background Mode" (Checking options for "Background Processing" & "Remote Notifications") in your app's Xcode project?
Have you created an APNs key in your Apple Developer account & uploaded this APNs key to your Firebase console?
Have you disabled method swizzling for Firebase in your app?
no such thing in our info.plist
Are you sending messages to your app from the Firebase Admin SDK?
Also tested with the project you recommend (flutterfire's nodeJS Firebase admin SDK script in previous section) :
Otherwise, we use the Java firebase library :
like :
Have you requested permission from the user to receive notifications?
Have you used the 'Console' application on your macOS device to check if the iOS device's system is throttling your background messages?
Additional context and comments
Briefly :
Our app is in Flutter
we make BG code to persist the notification in databse so that we can show it in an "history" screen (works 100% fine on Android and sometimes on iOS)
Android part works 100% of the time : -- Notifs received 100% of the time -- Notifs are 100% (BG) handled whether the app is in foreground, background, killed/terminated state, and even after device reboot.
iOS part "partly" works : -- Notifs received 100% of the time ! -- Notifs are (BG) Handled when app is in foreground, background and even if we kill/terminate the app after this by switching up the app in the recent apps list, notifications are still received and BG handled.
BUT AFTER THE IPHONE's REBOOT :
and as we can see in the MacOs console stackTrace screenshot :
What are we missing so that the BG part still works after the device's reboot on iOS !? Did i miss a configuration part or something ? a parameter maybe ? (We do use content-available : true and priority ones)
How to transform this "must not proceed" decision from iOS when receiving the notification (that, again, we do receive on the phone,) in "can proceed" or "must proceed" so that the background callback code works normally !?
Any help would be MUCH appreciated ! (^_^)
Thanks in advance.