Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ios/Runner/AppDelegate.swift uses the deprecated @UIApplicationMain attribute after updating to Flutter 3.24.0

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 ?

like image 948
Namsrai Khatanbaatar Avatar asked Oct 19 '25 11:10

Namsrai Khatanbaatar


1 Answers

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

like image 175
Ehsan Kalali Avatar answered Oct 21 '25 23:10

Ehsan Kalali