From 9f402b9ec1bf4c8eae91a1e87536e47bb4b1a074 Mon Sep 17 00:00:00 2001 From: dab246 Date: Tue, 23 May 2023 08:39:31 +0700 Subject: [PATCH] TF-1861 Config worker manager on iOS (cherry picked from commit a71422861efda154a79cc6c11d6fe190a88710dc) --- ios/Runner/AppDelegate.swift | 27 +++++++++++++++++++++------ ios/Runner/Info.plist | 7 ++++++- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/ios/Runner/AppDelegate.swift b/ios/Runner/AppDelegate.swift index b297e13eb..732d22e1f 100644 --- a/ios/Runner/AppDelegate.swift +++ b/ios/Runner/AppDelegate.swift @@ -3,23 +3,32 @@ import Flutter import flutter_downloader import receive_sharing_intent import flutter_local_notifications +import workmanager @UIApplicationMain @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( _ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? ) -> Bool { + /// Register the app's plugins in the context of a normal run + AppDelegate.registerPlugins(with: self) - FlutterLocalNotificationsPlugin.setPluginRegistrantCallback { (registry) in - GeneratedPluginRegistrant.register(with: registry) - } - if #available(iOS 10.0, *) { 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 if (!registry.hasPlugin("FlutterDownloaderPlugin")) { @@ -32,12 +41,18 @@ import flutter_local_notifications if url.scheme == "mailto" { if let url = handleEmailAndress(open: url) { let corrected = launchOptions!.map { (key, value) in key != .url ? (key, value) : (key, url) } - + return sharingIntent.application(application, didFinishLaunchingWithOptions: Dictionary(uniqueKeysWithValues: corrected)) } } } + WorkmanagerPlugin.setPluginRegistrantCallback { registry in + AppDelegate.registerPlugins(with: registry) + } + + WorkmanagerPlugin.registerTask(withIdentifier: "com.linagora.ios.teammail.sendingQueue") + return super.application(application, didFinishLaunchingWithOptions: launchOptions) } diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist index e96e78643..2ff0856c9 100644 --- a/ios/Runner/Info.plist +++ b/ios/Runner/Info.plist @@ -61,8 +61,13 @@ UIBackgroundModes fetch - remote-notification + remote-notification + processing + BGTaskSchedulerPermittedIdentifiers + + com.linagora.ios.teammail.sendingQueue + UILaunchStoryboardName LaunchScreen UIMainStoryboardFile