Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
curlyeto opened this issue Jul 15, 2020 · 1 comment · Fixed by #4012
Closed

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

curlyeto opened this issue Jul 15, 2020 · 1 comment · Fixed by #4012

Comments

@curlyeto
Copy link

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?

@TahaTesser
Copy link

Hi @curlyeto
Looks like there is an issue open for this
Closing duplicate of #2284

@firebase firebase locked and limited conversation to collaborators Aug 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants