2026-02-24 18:18:42 +08:00
|
|
|
import Flutter
|
2026-03-20 01:30:34 +08:00
|
|
|
import flutter_local_notifications
|
2026-02-24 18:18:42 +08:00
|
|
|
import UIKit
|
2026-03-18 17:03:22 +08:00
|
|
|
import UserNotifications
|
2026-02-24 18:18:42 +08:00
|
|
|
|
|
|
|
|
@main
|
|
|
|
|
@objc class AppDelegate: FlutterAppDelegate {
|
|
|
|
|
override func application(
|
|
|
|
|
_ application: UIApplication,
|
|
|
|
|
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
|
|
|
|
|
) -> Bool {
|
2026-03-20 01:30:34 +08:00
|
|
|
FlutterLocalNotificationsPlugin.setPluginRegistrantCallback { registry in
|
|
|
|
|
GeneratedPluginRegistrant.register(with: registry)
|
|
|
|
|
}
|
2026-02-24 18:18:42 +08:00
|
|
|
GeneratedPluginRegistrant.register(with: self)
|
2026-03-18 17:03:22 +08:00
|
|
|
if #available(iOS 10.0, *) {
|
|
|
|
|
UNUserNotificationCenter.current().delegate = self
|
|
|
|
|
}
|
2026-02-24 18:18:42 +08:00
|
|
|
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
|
|
|
|
|
}
|
2026-03-20 18:48:22 +08:00
|
|
|
|
|
|
|
|
override func userNotificationCenter(
|
|
|
|
|
_ center: UNUserNotificationCenter,
|
|
|
|
|
didReceive response: UNNotificationResponse,
|
|
|
|
|
withCompletionHandler completionHandler: @escaping () -> Void
|
|
|
|
|
) {
|
|
|
|
|
let userInfo = response.notification.request.content.userInfo
|
2026-03-20 19:34:06 +08:00
|
|
|
if let payloadString = userInfo["payload"] as? String {
|
|
|
|
|
UserDefaults.standard.set(payloadString, forKey: "pending_notification_payload")
|
2026-03-20 18:48:22 +08:00
|
|
|
}
|
|
|
|
|
completionHandler()
|
|
|
|
|
}
|
2026-02-24 18:18:42 +08:00
|
|
|
}
|