Swift中同步的没问题,异步的一直报Method is not invoked ,已经检查过版本,web的是^3.1.3,iOS的是3.0.2
DGLY opened this issue · comments
DGLY commented
iOS端
class AntzbJsBridgeabc: NSObject {
@objc func testSyn(args:Dictionary<String,Any>) -> String {
let msg = args["msg"] as? String ?? ""
return String(format:"%@[sync call:%@]", msg, "test")
}
@objc func testAsyn(arg:String, handler: (String, Bool)->Void) {
handler(String(format:"%@[async call:%@]", arg, "test"), true)
}
}
webview.addJavascriptObject(AntzbJsBridgeabc(), namespace: "abc")
Web端
this.msg = dsbridge.call("abc.testSyn", {a:"aa",b:12,msg:"asasas"}) //没问题
dsBridge.call("abc.testAsyn",'sassas', function (name) {//有问题,报Method is not invoked的错
this.msg = name
alert(name)
})
duwen commented
找到问题了?
DGLY commented
好像是我写错了,js那边我重新写了一下就好了....谢谢大哥
wenjuan5 commented
js那边怎么写才对啊,我也是这个问题,同步没错,异步报错这个