change message notify

This commit is contained in:
willem
2021-10-09 21:06:32 +08:00
parent de57d7254f
commit b126387fcf
3 changed files with 54 additions and 65 deletions

View File

@@ -5,18 +5,12 @@ import Foundation
public class CommonUtil {
public static func emitEvent(channel: FlutterMethodChannel, method: String, type: String, errCode: Int?, errMsg: String?, data: Any?){
DispatchQueue.main.async {
let res: NSMutableDictionary = NSMutableDictionary(capacity: 0)
res.setValue(type, forKey: "type")
if (data != nil) {
res.setValue(data, forKey: "data");
}
if (nil != errCode) {
res.setValue(errCode, forKey: "errCode");
}
if (nil != errMsg) {
res.setValue(errMsg, forKey: "errMsg");
}
safeMainAsync {
var res: [String: Any] = [:]
res["type"] = type
res["data"] = data
res["errCode"] = errCode
res["errMsg"] = errMsg
print("native call flutter { method: \(method) type: \(type) }")
channel.invokeMethod(method, arguments: res)
}