81 lines
2.6 KiB
Swift
81 lines
2.6 KiB
Swift
import Flutter
|
|
import UIKit
|
|
|
|
@main
|
|
@objc class AppDelegate: FlutterAppDelegate, FlutterImplicitEngineDelegate {
|
|
override func application(
|
|
_ application: UIApplication,
|
|
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
|
|
) -> Bool {
|
|
let result = super.application(application, didFinishLaunchingWithOptions: launchOptions)
|
|
|
|
if let controller = window?.rootViewController as? FlutterViewController {
|
|
// 1. Device Hardware Channel
|
|
let deviceChannel = FlutterMethodChannel(
|
|
name: "com.siro.siro_maps/device_hardware",
|
|
binaryMessenger: controller.binaryMessenger
|
|
)
|
|
deviceChannel.setMethodCallHandler { (call, callback) in
|
|
if call.method == "getHardwareInfo" {
|
|
var sysinfo = utsname()
|
|
uname(&sysinfo)
|
|
let machine = withUnsafePointer(to: &sysinfo.machine) {
|
|
$0.withMemoryRebound(to: CChar.self, capacity: 1) { ptr in
|
|
String(validatingUTF8: ptr)
|
|
}
|
|
} ?? UIDevice.current.model
|
|
|
|
let vendorId = UIDevice.current.identifierForVendor?.uuidString ?? ""
|
|
let info: [String: String] = [
|
|
"hardwareId": vendorId,
|
|
"brand": "Apple",
|
|
"manufacturer": "Apple",
|
|
"model": machine,
|
|
"device": UIDevice.current.model
|
|
]
|
|
callback(info)
|
|
} else {
|
|
callback(FlutterMethodNotImplemented)
|
|
}
|
|
}
|
|
|
|
// 2. Deep Link Channel
|
|
let deepLinkChannel = FlutterMethodChannel(
|
|
name: "com.siro.siro_maps/deep_link",
|
|
binaryMessenger: controller.binaryMessenger
|
|
)
|
|
deepLinkChannel.setMethodCallHandler { (call, callback) in
|
|
if call.method == "getInitialLink" {
|
|
callback(nil)
|
|
} else {
|
|
callback(FlutterMethodNotImplemented)
|
|
}
|
|
}
|
|
|
|
// 3. PiP Channel (Graceful unsupported on iOS)
|
|
let pipChannel = FlutterMethodChannel(
|
|
name: "com.siro.siro_maps/pip",
|
|
binaryMessenger: controller.binaryMessenger
|
|
)
|
|
pipChannel.setMethodCallHandler { (call, callback) in
|
|
switch call.method {
|
|
case "isPipSupported":
|
|
callback(false)
|
|
case "enterPictureInPicture":
|
|
callback(false)
|
|
case "setNavigating":
|
|
callback(true)
|
|
default:
|
|
callback(FlutterMethodNotImplemented)
|
|
}
|
|
}
|
|
}
|
|
|
|
return result
|
|
}
|
|
|
|
func didInitializeImplicitFlutterEngine(_ engineBridge: FlutterImplicitEngineBridge) {
|
|
GeneratedPluginRegistrant.register(with: engineBridge.pluginRegistry)
|
|
}
|
|
}
|