mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 15:24:35 +01:00
34 lines
1.3 KiB
Swift
34 lines
1.3 KiB
Swift
import UIKit
|
|
import WidgetKit
|
|
import Flutter
|
|
|
|
@main
|
|
@objc class AppDelegate: FlutterAppDelegate {
|
|
override func application(
|
|
_ application: UIApplication,
|
|
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
|
|
) -> Bool {
|
|
GeneratedPluginRegistrant.register(with: self)
|
|
|
|
let controller : FlutterViewController = window?.rootViewController as! FlutterViewController
|
|
let methodChannel = FlutterMethodChannel(name: "tech.lolli.toolbox/home_widget", binaryMessenger: controller.binaryMessenger)
|
|
methodChannel.setMethodCallHandler({(call: FlutterMethodCall, result: @escaping FlutterResult) -> Void in
|
|
if call.method == "update" {
|
|
if #available(iOS 14.0, *) {
|
|
WidgetCenter.shared.reloadTimelines(ofKind: "StatusWidget")
|
|
}
|
|
}
|
|
})
|
|
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
|
|
}
|
|
|
|
override func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
|
|
if url.scheme == "https" || url.scheme == "http" {
|
|
UIApplication.shared.open(url)
|
|
} else {
|
|
// Pass
|
|
}
|
|
return true
|
|
}
|
|
}
|