system_proxy/ios/Classes/SwiftSystemProxyPlugin.swift

19 lines
696 B
Swift
Raw Normal View History

2019-07-23 18:10:24 +08:00
import Flutter
import UIKit
public class SwiftSystemProxyPlugin: NSObject, FlutterPlugin {
public static func register(with registrar: FlutterPluginRegistrar) {
let channel = FlutterMethodChannel(name: "system_proxy", binaryMessenger: registrar.messenger())
let instance = SwiftSystemProxyPlugin()
registrar.addMethodCallDelegate(instance, channel: channel)
}
public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
if (call.method == "getProxySettings") {
let systemProxySettings = CFNetworkCopySystemProxySettings()?.takeUnretainedValue() ?? [:] as CFDictionary
result(systemProxySettings as NSDictionary);
return;
}
}
}