Skip to content

[firebase_messaging] On resume and on launch not trigger for IOS #2957

@curlyeto

Description

@curlyeto

Hi everyone.

Works in all situations on android but On launch and on resume do not trigger when app is in background or terminated.

Flutter doctor version

ertugrul@ertugruls-Mac ~ % flutter doctor -v
[✓] Flutter (Channel stable, v1.12.13+hotfix.8, on Mac OS X 10.15 19A602, locale
en-TR)
• Flutter version 1.12.13+hotfix.8 at /Users/ertugrul/flutter
• Framework revision 0b8abb4724 (5 months ago), 2020-02-11 11:44:36 -0800
• Engine revision e1e6ced81d
• Dart version 2.7.0

[!] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
• Android SDK at /Users/ertugrul/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling
support)
• Platform android-28, build-tools 29.0.3
• Java binary at: /Applications/Android
Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build
1.8.0_212-release-1586-b4-5784211)
✗ Android license status unknown.
Try re-installing or updating your Android SDK Manager.
See https://developer.android.com/studio/#downloads or visit
https://flutter.dev/setup/#android-setup for detailed instructions.

App Delegate.swift

import UIKit
import Flutter
import FirebaseMessaging

@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)
}
override func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
let deviceTokenString = deviceToken.reduce("", {$0 + String(format: "%02X", $1)})
print("==== didRegisterForRemoteNotificationsWithDeviceToken ====")
print(deviceTokenString)
Messaging.messaging().apnsToken = deviceToken
}
}

Fcm code

_fcm.configure(onMessage: (Map<String, dynamic> message) async {
print("onMessage tetkilendi: $message");
showNotification(message);
},
onBackgroundMessage: Platform.isIOS?null:myBackgroundMessageHandler,
onLaunch: (Map<String, dynamic> message) async {
print("onLaunch tetiklendi: $message");
showNotification(message);
},
onResume: (Map<String, dynamic> message) async {
print("onResume tetiklendi: $message");
showNotification(message);
},
);

Info.plist

<key>FirebaseAppDelegateProxyEnabled</key> <string>NO</string>

Firebase messagin version is 6.0.16. The code in the above on launch and on resume doesn't work print line when the above code is in the background or closed. Is there an error in the code I wrote or is it in the fcm package?

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