Skip to content

🐛 [firebase_messaging] FCM data message not coming when app is closed in ios #6921

@arif2k17-hot

Description

@arif2k17-hot

I have integrated FCM in my flutter project with flutter_local_notification. Everything works as expected in Android. However, ios also works almost except when app is closed from history. When app is cleared from history messages are not triggering. I am using only data message in push notification. Please have a look below:

{
   "to": "/topics/global",
   "priority": "high",
   "content_available": true,
   "data": {
      "title": "Demo Title",
      "message": "Demo Message",
      "payload": "basic"
   }
}

As you can see there is no notification object in the json. This configuration is working fine on Android (foreground & background) and for ios only foreground. However, if i add the notification object in this json surprisingly it works even the app is closed.

But as i need to handle the notification manually that option doesn't fit for my use case. So i researched further and disabled Method Swizzling

<key>FirebaseAppDelegateProxyEnabled</key> 
<false/>

But that didn't help either. Now i'm kinda lost and can't find a way to achieve expected result. My AppDelegate.swift is given below

import UIKit
import Flutter

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
   override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
    GeneratedPluginRegistrant.register(with: self)
    if #available(iOS 10.0, *) {
      UNUserNotificationCenter.current().delegate = self as UNUserNotificationCenterDelegate
    }
    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }
}

NOTE: The ios app is published in TestFlight and testing on a real device

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs AttentionThis issue needs maintainer attention.resolution: invalidThis doesn't seem right and might not belong here.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