Commit 5e3f9e299a69700d156936e3d47897ca6113830d

Authored by 权海
1 parent a388346a

feat(ui):调整ios AppDelegate

@@ -13,11 +13,11 @@ import AppTrackingTransparency @@ -13,11 +13,11 @@ import AppTrackingTransparency
13 import AdSupport 13 import AdSupport
14 14
15 @Observable 15 @Observable
16 -class AppDelegate: FlutterAppDelegate { 16 +class AppDelegate: NSObject, UIApplicationDelegate {
17 17
18 let flutterEngine: FlutterEngine = FlutterEngine(name: "main_flutter_engine") 18 let flutterEngine: FlutterEngine = FlutterEngine(name: "main_flutter_engine")
19 19
20 - override func application( 20 + func application(
21 _ application: UIApplication, 21 _ application: UIApplication,
22 didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? 22 didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
23 ) -> Bool { 23 ) -> Bool {
@@ -32,11 +32,11 @@ class AppDelegate: FlutterAppDelegate { @@ -32,11 +32,11 @@ class AppDelegate: FlutterAppDelegate {
32 NativePigeonRegistrar.register(binaryMessenger: flutterEngine.binaryMessenger) 32 NativePigeonRegistrar.register(binaryMessenger: flutterEngine.binaryMessenger)
33 WatchConnectivityService.shared.activate() 33 WatchConnectivityService.shared.activate()
34 HealthKitService.shared.startBackgroundObserversIfNeeded() 34 HealthKitService.shared.startBackgroundObserversIfNeeded()
35 -  
36 - return super.application(application, didFinishLaunchingWithOptions: launchOptions) 35 +//
  36 + return true
37 } 37 }
38 38
39 - override func application(_ application: UIApplication, 39 + func application(_ application: UIApplication,
40 didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) { 40 didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
41 let tokenParts = deviceToken.map { data in String(format: "%02.2hhx", data) } 41 let tokenParts = deviceToken.map { data in String(format: "%02.2hhx", data) }
42 let token = tokenParts.joined() 42 let token = tokenParts.joined()
@@ -44,18 +44,20 @@ class AppDelegate: FlutterAppDelegate { @@ -44,18 +44,20 @@ class AppDelegate: FlutterAppDelegate {
44 print("✅ Device Token: \(token)") 44 print("✅ Device Token: \(token)")
45 } 45 }
46 46
47 - override func application(_ application: UIApplication, 47 + func application(_ application: UIApplication,
48 didFailToRegisterForRemoteNotificationsWithError error: Error) { 48 didFailToRegisterForRemoteNotificationsWithError error: Error) {
49 print("❌ Failed to register: \(error.localizedDescription)") 49 print("❌ Failed to register: \(error.localizedDescription)")
50 } 50 }
51 -  
52 - override func userNotificationCenter(_ center: UNUserNotificationCenter, 51 +}
  52 +
  53 +extension AppDelegate: UNUserNotificationCenterDelegate{
  54 + func userNotificationCenter(_ center: UNUserNotificationCenter,
53 willPresent notification: UNNotification, 55 willPresent notification: UNNotification,
54 withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) { 56 withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
55 completionHandler([.banner, .sound, .badge]) 57 completionHandler([.banner, .sound, .badge])
56 } 58 }
57 59
58 - override func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) { 60 + func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
59 let userInfo = response.notification.request.content.userInfo 61 let userInfo = response.notification.request.content.userInfo
60 62
61 // 从通知中获取 URL 63 // 从通知中获取 URL
@@ -76,7 +78,6 @@ class AppDelegate: FlutterAppDelegate { @@ -76,7 +78,6 @@ class AppDelegate: FlutterAppDelegate {
76 } 78 }
77 } 79 }
78 80
79 -  
80 extension AppDelegate { 81 extension AppDelegate {
81 private func requestIDFAAuthorization() { 82 private func requestIDFAAuthorization() {
82 if ATTrackingManager.trackingAuthorizationStatus == .notDetermined { 83 if ATTrackingManager.trackingAuthorizationStatus == .notDetermined {
@@ -67,19 +67,19 @@ class MyTab extends GetView<MyController> { @@ -67,19 +67,19 @@ class MyTab extends GetView<MyController> {
67 title: context.l10n.help, 67 title: context.l10n.help,
68 onTap: () => Get.toNamed(Routes.HELP), 68 onTap: () => Get.toNamed(Routes.HELP),
69 ), 69 ),
70 - if (kDebugMode) ...[  
71 - const SizedBox(height: 12), 70 + const SizedBox(height: 12),
72 _SettingsRow( 71 _SettingsRow(
73 - title: 'Route List', 72 + title: 'Apple Health Upload 测试',
74 onTap: () { 73 onTap: () {
75 - Get.toNamed(Routes.ROUTE_LIST); 74 + controller.testAppleHealthUpload();
76 }, 75 },
77 ), 76 ),
  77 + if (kDebugMode) ...[
78 const SizedBox(height: 12), 78 const SizedBox(height: 12),
79 _SettingsRow( 79 _SettingsRow(
80 - title: 'Apple Health Upload 测试', 80 + title: 'Route List',
81 onTap: () { 81 onTap: () {
82 - controller.testAppleHealthUpload(); 82 + Get.toNamed(Routes.ROUTE_LIST);
83 }, 83 },
84 ), 84 ),
85 ], 85 ],