I must have set up things correctly because onResume and onLaunch works perfectly in Android physical devices. However, when I run iOS, I cannot get onLaunch and onResume to fire. I am receiving push notification correctly though (it fills the tray). Below is my configuration code
_firebaseMessaging.configure(
onMessage: (Map<String, dynamic> message) async {
print('run onMessage');
print("onMessage: $message");
if (message['notification'] != null) {
final noti = message['notification'];
final String title = noti['title'];
final String body = noti['body'];
}
},
onLaunch: (Map<String, dynamic> message) async {
print('run onLaunch');
print('onLaunch: $message');
setState(() {
testInt = 2;
});
keySingleton.navigatorKey.currentState.pushAndRemoveUntil(
MaterialPageRoute(
builder: (_) => WebView(
initialUrl: _getUrl(message),
),
),
(_) => false,
);
},
onResume: (Map<String, dynamic> message) async {
print('run onResume');
print("onResume: $message");
setState(() {
testInt = 1;
});
await Future.delayed(
const Duration(seconds: 2),
);
keySingleton.navigatorKey.currentState.pushAndRemoveUntil(
MaterialPageRoute(
builder: (_) => WebView(
initialUrl: _getUrl(message),
),
),
(_) => false,
);
},
);
Flutter doctor below
[✓] Flutter (Channel beta, v1.12.13+hotfix.1, on Mac OS X 10.14.5 18F132, locale en-KR)
• Flutter version 1.12.13+hotfix.1 at /Users/jc/Documents/resources/libraries/flutter
• Framework revision 5b07015393 (9 days ago), 2019-12-03 00:12:02 -0800
• Engine revision c1e322b685
• Dart version 2.7.0
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
• Android SDK at /Users/jc/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-29, build-tools 28.0.3
• ANDROID_HOME = /Users/jc/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 11.3)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 11.3, Build version 11C29
• CocoaPods version 1.7.5
[✓] Android Studio (version 3.3)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 33.4.1
• Dart plugin version 182.5215
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)
[✓] IntelliJ IDEA Ultimate Edition (version 2019.2.3)
• IntelliJ at /Applications/IntelliJ IDEA.app
• Flutter plugin version 40.2.4
• Dart plugin version 192.6817.14
[✓] VS Code (version 1.40.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.6.0
• No issues found!
Please at least just throw me something that I can try. Thanks
I think I may have the same problem, I could make the callback works by removing the lines added at step 5 of iOS Integration from the doc.
I don't really know what these lines do and if removing them could cause other issues on other versions.
@iapicca is the solution @DamienMrtl is suggesting a viable one? Does it have any sideffects?
I must have set up things correctly because onResume and onLaunch works perfectly in Android physical devices. However, when I run iOS, I cannot get onLaunch and onResume to fire. I am receiving push notification correctly though (it fills the tray). Below is my configuration code
_firebaseMessaging.configure( onMessage: (Map<String, dynamic> message) async { print('run onMessage'); print("onMessage: $message"); if (message['notification'] != null) { final noti = message['notification']; final String title = noti['title']; final String body = noti['body']; } }, onLaunch: (Map<String, dynamic> message) async { print('run onLaunch'); print('onLaunch: $message'); setState(() { testInt = 2; }); keySingleton.navigatorKey.currentState.pushAndRemoveUntil( MaterialPageRoute( builder: (_) => WebView( initialUrl: _getUrl(message), ), ), (_) => false, ); }, onResume: (Map<String, dynamic> message) async { print('run onResume'); print("onResume: $message"); setState(() { testInt = 1; }); await Future.delayed( const Duration(seconds: 2), ); keySingleton.navigatorKey.currentState.pushAndRemoveUntil( MaterialPageRoute( builder: (_) => WebView( initialUrl: _getUrl(message), ), ), (_) => false, ); }, );Flutter doctor below
[✓] Flutter (Channel beta, v1.12.13+hotfix.1, on Mac OS X 10.14.5 18F132, locale en-KR) • Flutter version 1.12.13+hotfix.1 at /Users/jc/Documents/resources/libraries/flutter • Framework revision 5b07015393 (9 days ago), 2019-12-03 00:12:02 -0800 • Engine revision c1e322b685 • Dart version 2.7.0 [✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3) • Android SDK at /Users/jc/Library/Android/sdk • Android NDK location not configured (optional; useful for native profiling support) • Platform android-29, build-tools 28.0.3 • ANDROID_HOME = /Users/jc/Library/Android/sdk • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 11.3) • Xcode at /Applications/Xcode.app/Contents/Developer • Xcode 11.3, Build version 11C29 • CocoaPods version 1.7.5 [✓] Android Studio (version 3.3) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin version 33.4.1 • Dart plugin version 182.5215 • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01) [✓] IntelliJ IDEA Ultimate Edition (version 2019.2.3) • IntelliJ at /Applications/IntelliJ IDEA.app • Flutter plugin version 40.2.4 • Dart plugin version 192.6817.14 [✓] VS Code (version 1.40.2) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.6.0 • No issues found!Please at least just throw me something that I can try. Thanks
Have you test on android 9.0 ?? I got problem on android 9.0
@serendipity1004 were you able to get things working again? I'm having the same issues
I think I may have the same problem, I could make the callback works by removing the lines added at step 5 of iOS Integration from the doc.
I don't really know what these lines do and if removing them could cause other issues on other versions.
This is working for me too. Obviously not the best idea to remove that line but I guess a working bad solution is better than a non-working great one!
@DamienMrtl @mahdi-ninja can you please share your FlutterAppDelegate code ?
import UIKit
import Flutter
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
// didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?
//)
-> Bool {
GeneratedPluginRegistrant.register(with: self)
if #available(iOS 10.0, *) {
UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate
}
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}
Here's my AppDelegate right now
```objc
@implementation AppDelegate
(BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[GeneratedPluginRegistrant registerWithRegistry:self];
// Override point for customization after application launch.
// TODO: figure out why we need to comment this line!
// if (@available(iOS 10.0, *)) {
// [UNUserNotificationCenter currentNotificationCenter].delegate = (id
// }
return [super application:application didFinishLaunchingWithOptions:launchOptions];
}
@end
Hey all 👋
As part of our roadmap (#2582) we've just shipped a complete rework of the firebase_messaging plugin that aims to solve this and many other issues.
If you can, please try out the dev release (see the migration guide for upgrading and for changes) and if you have any feedback then join in the discussion here.
Given the scope of the rework I'm going to go ahead and close this issue in favor of trying out the latest plugin.
Thanks everyone.
Most helpful comment
I think I may have the same problem, I could make the callback works by removing the lines added at step 5 of iOS Integration from the doc.
I don't really know what these lines do and if removing them could cause other issues on other versions.