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 ?
You should use this way Thanks from @StefanCiobotaru for this solution.
Also you have an error like this:
Error (Xcode): /hosted/pub.dev/win32-5.2.0/lib/src/guid.dart:32:9: Error: Type 'UnmodifiableUint8ListView' not found
You must do these some steps:
1- flutter pub cache clean
2- flutter pub get
3- flutter pub upgrade
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With