-
-
Save Wenomok/ea1cf6775ade93e8df2d150eb3bf2557 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@objc class AppDelegate: FlutterAppDelegate { | |
let hubMethodChannel: HubMethodChannel = .init() | |
override func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { | |
hubMethodChannel.handle() | |
GeneratedPluginRegistrant.register(with: self) | |
return super.application(application, didFinishLaunchingWithOptions: launchOptions) | |
} | |
} | |
class HubMethodChannel: NSObject { | |
func handle() { | |
if let controller = UIApplication.shared.delegate?.window??.rootViewController as? FlutterViewController { | |
let connectToHubChannel = FlutterMethodChannel(name: "dexbee.club/HubConfig", | |
binaryMessenger: controller.binaryMessenger) | |
connectToHubChannel.setMethodCallHandler({ | |
(call: FlutterMethodCall, result: @escaping FlutterResult) -> Void in | |
switch call.method { | |
case "scanWiFiHubList": | |
HubManager.shared.scanWiFiList { wifiModelList in | |
result(wifiModelList.map({ $0.toDictResult() })) | |
} onError: { error in | |
result(error.toFlutterError()) | |
} | |
default: | |
result(FlutterMethodNotImplemented) | |
} | |
}) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment