ソースを参照

add:添加处理后台任务

zhoukun 7 ヶ月 前
コミット
3cf1ee4a89
2 ファイル変更8 行追加0 行削除
  1. 4 0
      ios/Runner/AppDelegate.swift
  2. 4 0
      ios/Runner/Info.plist

+ 4 - 0
ios/Runner/AppDelegate.swift

@@ -1,5 +1,6 @@
 import Flutter
 import UIKit
+import BackgroundTasks
 
 @main
 @objc class AppDelegate: FlutterAppDelegate {
@@ -8,6 +9,9 @@ import UIKit
     didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
   ) -> Bool {
     GeneratedPluginRegistrant.register(with: self)
+    BGTaskScheduler.shared.register(forTaskWithIdentifier: "com.shishi.dingwei.refresh", using: nil) { task in
+      // 处理后台任务
+    }
     return super.application(application, didFinishLaunchingWithOptions: launchOptions)
   }
 }

+ 4 - 0
ios/Runner/Info.plist

@@ -59,6 +59,10 @@
 		<string>fetch</string>
 		<string>processing</string>
 	</array>
+    <key>BGTaskSchedulerPermittedIdentifiers</key>
+    <array>
+        <string>com.shishi.dingwei.refresh</string>
+    </array>
 	<key>UILaunchStoryboardName</key>
 	<string>LaunchScreen</string>
 	<key>UIMainStoryboardFile</key>