-
Notifications
You must be signed in to change notification settings - Fork 69
/
Copy pathSwiftSystemAlertWindowPlugin.swift
23 lines (21 loc) · 1.07 KB
/
SwiftSystemAlertWindowPlugin.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import Flutter
import UIKit
public class SwiftSystemAlertWindowPlugin: NSObject, FlutterPlugin {
public static func register(with registrar: FlutterPluginRegistrar) {
let channel = FlutterMethodChannel(name: "system_alert_window", binaryMessenger: registrar.messenger())
let instance = SwiftSystemAlertWindowPlugin()
registrar.addMethodCallDelegate(instance, channel: channel)
}
public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
if (call.method == "getPlatformVersion") {
result("iOS " + UIDevice.current.systemVersion)
}
else if (call.method == "showSystemWindow") {
DispatchQueue.main.async {
let alert = UIAlertController(title: "Alert", message: "Hi, My name is flutter", preferredStyle: .alert);
alert.addAction(UIAlertAction(title: "OK", style: UIAlertAction.Style.default, handler: nil))
UIApplication.shared.keyWindow?.rootViewController?.present(alert, animated: true, completion: nil);
}
}
}
}