2025年7月1日星期二

2025 flutter local notification AppDelegate.swift (flutter 3.27.2)

 import Flutter


import UIKit


import UserNotifications // Import UserNotifications framework




@main


@objc class AppDelegate: FlutterAppDelegate {




  override func application(


    _ application: UIApplication,


    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?


  ) -> Bool {


    // Add this line to set the UNUserNotificationCenter delegate


    if #available(iOS 10.0, *) {


      UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate


    }




    GeneratedPluginRegistrant.register(with: self)


    return super.application(application, didFinishLaunchingWithOptions: launchOptions)


  }


}

==============================================================

if error:

 Unhandled Exception: [firebase_messaging/apns-token-not-set] "APNS token has not been set yet." Please ensure the APNS token is available by calling `getAPNSToken()`.













沒有留言:

發佈留言