TF-1861 Config worker manager on iOS

(cherry picked from commit a71422861efda154a79cc6c11d6fe190a88710dc)
This commit is contained in:
dab246
2023-05-23 08:39:31 +07:00
committed by Dat Vu
parent 9550982e73
commit 9f402b9ec1
2 changed files with 27 additions and 7 deletions
+20 -5
View File
@@ -3,23 +3,32 @@ import Flutter
import flutter_downloader import flutter_downloader
import receive_sharing_intent import receive_sharing_intent
import flutter_local_notifications import flutter_local_notifications
import workmanager
@UIApplicationMain @UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate { @objc class AppDelegate: FlutterAppDelegate {
/// Registers all pubspec-referenced Flutter plugins in the given registry.
static func registerPlugins(with registry: FlutterPluginRegistry) {
GeneratedPluginRegistrant.register(with: registry)
}
override func application( override func application(
_ application: UIApplication, _ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool { ) -> Bool {
/// Register the app's plugins in the context of a normal run
FlutterLocalNotificationsPlugin.setPluginRegistrantCallback { (registry) in AppDelegate.registerPlugins(with: self)
GeneratedPluginRegistrant.register(with: registry)
}
if #available(iOS 10.0, *) { if #available(iOS 10.0, *) {
UNUserNotificationCenter.current().delegate = self as UNUserNotificationCenterDelegate UNUserNotificationCenter.current().delegate = self as UNUserNotificationCenterDelegate
} }
GeneratedPluginRegistrant.register(with: self) UIApplication.shared.setMinimumBackgroundFetchInterval(TimeInterval(60*15))
FlutterLocalNotificationsPlugin.setPluginRegistrantCallback { registry in
AppDelegate.registerPlugins(with: registry)
}
FlutterDownloaderPlugin.setPluginRegistrantCallback { registry in FlutterDownloaderPlugin.setPluginRegistrantCallback { registry in
if (!registry.hasPlugin("FlutterDownloaderPlugin")) { if (!registry.hasPlugin("FlutterDownloaderPlugin")) {
@@ -38,6 +47,12 @@ import flutter_local_notifications
} }
} }
WorkmanagerPlugin.setPluginRegistrantCallback { registry in
AppDelegate.registerPlugins(with: registry)
}
WorkmanagerPlugin.registerTask(withIdentifier: "com.linagora.ios.teammail.sendingQueue")
return super.application(application, didFinishLaunchingWithOptions: launchOptions) return super.application(application, didFinishLaunchingWithOptions: launchOptions)
} }
+6 -1
View File
@@ -61,8 +61,13 @@
<key>UIBackgroundModes</key> <key>UIBackgroundModes</key>
<array> <array>
<string>fetch</string> <string>fetch</string>
<string>remote-notification</string> <string>remote-notification</string>
<string>processing</string>
</array> </array>
<key>BGTaskSchedulerPermittedIdentifiers</key>
<array>
<string>com.linagora.ios.teammail.sendingQueue</string>
</array>
<key>UILaunchStoryboardName</key> <key>UILaunchStoryboardName</key>
<string>LaunchScreen</string> <string>LaunchScreen</string>
<key>UIMainStoryboardFile</key> <key>UIMainStoryboardFile</key>