I am working on the firebase push notification in ios project and I am successfully receiving the notification for the iOS and Android both but for the iOS I am not able to receive onResume and onLanch call back in the flutter side when I tap on the notification.
Firebase_messaging is updated on the latest version (firebase_messaging: ^6.0.16)
- Firebase configuration:
setFirebase() async {
_fireBaseMessaging.requestNotificationPermissions(
const IosNotificationSettings(sound: true, badge: true, alert: true));
_fireBaseMessaging.configure(
// ignore: missing_return
onMessage: (Map<String, dynamic> msg) {
print('onMessage $msg');
},
onResume: (Map<String, dynamic> msg) async {
print('onResume $msg');
},
onLaunch: (Map<String, dynamic> msg) async {
print('onLaunch $msg');
},
);
_fireBaseMessaging.onIosSettingsRegistered
.listen((IosNotificationSettings settings) {
print("IOS NOTIFICATION SETTING");
});
}
For the same code, I am receiving the acknowledge of
onLanchandonResumein my android app.AppDelegate.swift:
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate{
override func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
FirebaseApp.configure()
GeneratedPluginRegistrant.register(with: self)
UNUserNotificationCenter.current().delegate = self
application.registerForRemoteNotifications()
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge]) { (granted, error) in
// Enable or disable features based on authorization.
if granted
{
DispatchQueue.main.async(execute: {
UIApplication.shared.registerForRemoteNotifications()
})
}
else
{
print("Don't Allow")
}
}
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
override func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void)
{
completionHandler([.alert, .badge, .sound])
}
}