You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
you can simply call method webView.bridge.evaluate("testAlert()") if you want to call testAlert from Swift code, but you should not call it in viewDidLoad (webview doesn't load at that time, try to call it after 2 seconds or after the callback webViewDidFinishLoad).
if you want to listen callback from swift code, you should Notify using completion to callback when register actions.
webView.bridge.register({[weak self](parameters, completion)in
guard let strongSelf =self,let parameters = parameters else{return}// THIS IS IMPORTANTcompletion(.success(["button_index":1]))}, for:"alert")
and a handler when post message
functiontestAlert(){window.bridge.post('alert',{'title': 'This is alert title','message': 'This is alert message'},(results,error)=>{// THIS IS IMPORTANT , })}
callback on swift when call js is just the return value from javascript.
function foo(){return{"foo":"bar"}}
webView.bridge.evaluate("testAlert()", completion:(result, error){// result is {"foo": "bar"}})
I'm looking around on you library and testing some code.
HTML code:
Swift code:
How to get the callback on Swift work? How can I call testAlert from Swift code?
Thanks.
The text was updated successfully, but these errors were encountered: