I recently updated my Flutter project to version 3.24.0, and now I’m getting a warning about the use of the deprecated @UIApplicationMain attribute in my ios/Runner/AppDelegate.swift file.
Here is my AppDelegate.swift file.
import UIKit
import Flutter
import FirebaseMessaging
import Firebase
import UserNotifications
import flutter_local_notifications
@main
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
GeneratedPluginRegistrant.register(with: self)
// This is required to make any communication available in the action isolate.
FlutterLocalNotificationsPlugin.setPluginRegistrantCallback { (registry) in
GeneratedPluginRegistrant.register(with: registry)
}
if(FirebaseApp.app() == nil){
FirebaseApp.configure()
}
UNUserNotificationCenter.current().delegate = self
if #available(iOS 10.0, *) {
UNUserNotificationCenter.current().delegate = self as UNUserNotificationCenterDelegate
}
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
// This method will be called when app received push notifications in foreground
override func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void)
{
completionHandler([.alert, .badge, .sound])
}
}
Questions:
What is the recommended way to update AppDelegate.swift to remove the deprecated @UIApplicationMain attribute?
Are there any other changes I should be aware of when upgrading Flutter to 3.24.0 related to iOS development?
Any solution for this ?