Skip to content

[firebase_messaging]: FCM Notifications Not Displayed When App Opens from Background/Terminated State #17939

@usama-sherazi

Description

@usama-sherazi

Is there an existing issue for this?

  • I have searched the existing issues.

Are you aware of the differences between iOS and Android background message handling?

  • I understand that iOS and Android background messages behave differently, and I've designed my application with that in mind.

Do you have an active Apple Developer account?

  • I have an active Apple Developer account.

Are you using a physical iOS device to test background messages?

  • I am 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?

Problem
When the app is in background or terminated, FCM notifications are received but not shown in the app when it opens. Messages received while the app was closed are not available in the app.
Current Behavior
Background/terminated: Notifications are received and saved via _firebaseMessagingBackgroundHandler
App opens: No code retrieves the initial message using FirebaseMessaging.instance.getInitialMessage()
Result: Messages received while app was closed are not displayed
Expected Behavior
When app opens from terminated state, check for initial message using getInitialMessage()
Display messages received in background/terminated state in the app
Process notifications that arrived while app was closed
Code References
Background handler saves notifications:
main.dartLines ``

Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async {  // ... saves notifications to device storage}
Foreground listener handles active app messages:
main.dartLines 509-583
void setupForegroundMessageListener() {  FirebaseMessaging.onMessage.listen((RemoteMessage message) async {    // ... handles foreground messages  });}

Technical Details
Firebase Core: ^4.3.0
Firebase Messaging: ^16.1.0
Platforms: Android & iOS

Have you created an APNs key in your Apple Developer account & uploaded this APNs key to your Firebase console?

yes uploaded

Have you disabled method swizzling for Firebase in your app?

Image

Are you sending messages to your app from the Firebase Admin SDK?

{
"action": "ring",
"result": "ok",
"mac": ":F78:xx:0xx0:05:03",
"ip": "192.1x.x.x",
"img": "data:imag
}

Have you requested permission from the user to receive notifications?

  • I have the relevant permission 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?

no

Additional context and comments

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    blocked: customer-responseWaiting for customer response, e.g. more information was requested.platform: iosIssues / PRs which are specifically for iOS.plugin: messagingresolution: userThis was a user issue, e.g. invalid configuration or code.type: bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions