Update: BackgroundServicePlugin

This commit is contained in:
2022-05-07 23:03:16 +08:00
parent 105ff6446b
commit 4d95357fcb
2 changed files with 15 additions and 8 deletions
+1 -1
View File
@@ -211,4 +211,4 @@ SPEC CHECKSUMS:
PODFILE CHECKSUM: 472b36355d7f1afce121640438e776da12affe90 PODFILE CHECKSUM: 472b36355d7f1afce121640438e776da12affe90
COCOAPODS: 1.11.2 COCOAPODS: 1.11.3
+14 -7
View File
@@ -1,18 +1,25 @@
import UIKit import UIKit
import Flutter import Flutter
import flutter_downloader import flutter_downloader
import flutter_background_service
@UIApplicationMain @UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate { @objc class AppDelegate: FlutterAppDelegate {
override func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { override func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
GeneratedPluginRegistrant.register(with: self) AppDelegate.registerPlugins(with: self)
FlutterDownloaderPlugin.setPluginRegistrantCallback(registerPlugins) FlutterDownloaderPlugin.setPluginRegistrantCallback { registry in
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}
private func registerPlugins(registry: FlutterPluginRegistry) {
if (!registry.hasPlugin("FlutterDownloaderPlugin")) { if (!registry.hasPlugin("FlutterDownloaderPlugin")) {
FlutterDownloaderPlugin.register(with: registry.registrar(forPlugin: "FlutterDownloaderPlugin")!) FlutterDownloaderPlugin.register(with: registry.registrar(forPlugin: "FlutterDownloaderPlugin")!)
} }
}
SwiftFlutterBackgroundServicePlugin.setPluginRegistrantCallback { registry in
AppDelegate.registerPlugins(with: registry)
}
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
static func registerPlugins(with registry: FlutterPluginRegistry) {
GeneratedPluginRegistrant.register(with: registry)
}
} }