Skip to content

[iOS] onResume callback get called when the app receiving the remote notification in background mode #102

Open
@tc14077

Description

@tc14077

Hi folks, I am new to this package. I am working with the latest version of this package, flutter_apns_only: ^1.6.0.

I am getting confused about the definition of onResume. Under my understanding, the onResume is getting called, when the user taps on the notification with the app in the background. However, I figure out this onResume is also getting called while the app receives the remote notification. After deep diving into the implementation of the iOS platform code, I found this code snippet.

// this callback is getting called when the app receive the RemoteNotification
public func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) -> Bool {
        let userInfo = FlutterApnsSerialization.remoteMessageUserInfo(toDict: userInfo)
        
        if resumingFromBackground {
            onResume(userInfo: userInfo) // this line making onResume call to flutter layer, however the app is not actually "resumingFromBackground", this flag is only indicating the app is in the "background"
        } else {
            channel.invokeMethod("onMessage", arguments: userInfo)
        }
        
        completionHandler(.noData)
        return true
    }

Maybe I have a wrong understanding of the onResume definition. If that is the case, can someone please suggest a way for me to identify whether the user is resuming the app through click the notification?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions