You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.2 KiB
40 lines
1.2 KiB
import Flutter
|
|
import UIKit
|
|
|
|
/// iOS 悬浮窗权限插件
|
|
/// 为了与 Android 版本保持接口一致性而创建
|
|
public class OverlayPermissionPlugin: NSObject, FlutterPlugin {
|
|
|
|
// MARK: - 常量
|
|
private static let channelName = "overlay_permission"
|
|
|
|
// MARK: - 插件注册
|
|
public static func register(with registrar: FlutterPluginRegistrar) {
|
|
let instance = OverlayPermissionPlugin()
|
|
|
|
// 创建方法通道
|
|
let methodChannel = FlutterMethodChannel(
|
|
name: channelName,
|
|
binaryMessenger: registrar.messenger()
|
|
)
|
|
registrar.addMethodCallDelegate(instance, channel: methodChannel)
|
|
|
|
print("OverlayPermissionPlugin 注册成功")
|
|
}
|
|
|
|
// MARK: - 方法调用处理
|
|
public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
|
|
switch call.method {
|
|
case "hasOverlayPermission":
|
|
// iOS 使用应用内悬浮窗,不需要特殊权限
|
|
result(true)
|
|
|
|
case "requestOverlayPermission":
|
|
// iOS 使用应用内悬浮窗,不需要特殊权限
|
|
result(true)
|
|
|
|
default:
|
|
result(FlutterMethodNotImplemented)
|
|
}
|
|
}
|
|
}
|
|
|