|
...
|
...
|
@@ -13,11 +13,11 @@ import AppTrackingTransparency |
|
|
|
import AdSupport
|
|
|
|
|
|
|
|
@Observable
|
|
|
|
class AppDelegate: FlutterAppDelegate {
|
|
|
|
class AppDelegate: NSObject, UIApplicationDelegate {
|
|
|
|
|
|
|
|
let flutterEngine: FlutterEngine = FlutterEngine(name: "main_flutter_engine")
|
|
|
|
|
|
|
|
override func application(
|
|
|
|
func application(
|
|
|
|
_ application: UIApplication,
|
|
|
|
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
|
|
|
|
) -> Bool {
|
|
...
|
...
|
@@ -32,11 +32,11 @@ class AppDelegate: FlutterAppDelegate { |
|
|
|
NativePigeonRegistrar.register(binaryMessenger: flutterEngine.binaryMessenger)
|
|
|
|
WatchConnectivityService.shared.activate()
|
|
|
|
HealthKitService.shared.startBackgroundObserversIfNeeded()
|
|
|
|
|
|
|
|
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
|
|
|
|
//
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
override func application(_ application: UIApplication,
|
|
|
|
func application(_ application: UIApplication,
|
|
|
|
didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
|
|
|
|
let tokenParts = deviceToken.map { data in String(format: "%02.2hhx", data) }
|
|
|
|
let token = tokenParts.joined()
|
|
...
|
...
|
@@ -44,18 +44,20 @@ class AppDelegate: FlutterAppDelegate { |
|
|
|
print("✅ Device Token: \(token)")
|
|
|
|
}
|
|
|
|
|
|
|
|
override func application(_ application: UIApplication,
|
|
|
|
func application(_ application: UIApplication,
|
|
|
|
didFailToRegisterForRemoteNotificationsWithError error: Error) {
|
|
|
|
print("❌ Failed to register: \(error.localizedDescription)")
|
|
|
|
}
|
|
|
|
|
|
|
|
override func userNotificationCenter(_ center: UNUserNotificationCenter,
|
|
|
|
}
|
|
|
|
|
|
|
|
extension AppDelegate: UNUserNotificationCenterDelegate{
|
|
|
|
func userNotificationCenter(_ center: UNUserNotificationCenter,
|
|
|
|
willPresent notification: UNNotification,
|
|
|
|
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
|
|
|
|
completionHandler([.banner, .sound, .badge])
|
|
|
|
}
|
|
|
|
|
|
|
|
override func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
|
|
|
|
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
|
|
|
|
let userInfo = response.notification.request.content.userInfo
|
|
|
|
|
|
|
|
// 从通知中获取 URL
|
|
...
|
...
|
@@ -76,7 +78,6 @@ class AppDelegate: FlutterAppDelegate { |
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
extension AppDelegate {
|
|
|
|
private func requestIDFAAuthorization() {
|
|
|
|
if ATTrackingManager.trackingAuthorizationStatus == .notDetermined {
|
...
|
...
|
|