Andrews, IOS embedded in mutual communication H5

A, h5 trigger Andrews calls the function:

JavaScriptHandler.onActionResult(type)

1, JavascriptHandler intermediate object is defined Andrews.

2, onActionResult for the method name as mutually agreed; type parameter can not pass pass (it is best to pass, IOS does not pass, then can not trigger);

Two, h5 reception parameter returned Andrews

= window.reTvInfo function (RES) { 
     // logic overheard method returns after 
}

1, mounted directly on the window in a global method, after the call ends Andrews, js triggers in this method, as the method according to the present embodiment is reTvInfo. Andrews received value returned res

 

 

Three, h5 trigger IOS call functions

window.webkit.messageHandlers.partnerOpenScan.postMessage("调用扫码");

The amount of intermediate 1, messageHandlers as defined IOS

2, partnerOpenScan for the Android terminal method name to invoke = "mean to tell IOS call the method

3, postMessage fixed wording

4, IOS must be passed parameters. Or can not trigger IOS method

 

Four, h5 receiving return values ​​IOS

= window.partnerReturnInfo function (dt) {
        // overheard processing logic returns after IOS 
}

 

V. Summary

  Andrews IOS embedded h5 are achieved by a communication window overall volume, receiving a return function is mounted on the window, then the app end active calls.

  Trigger method will be different, particular attention must be parameterized to trigger the IOS

Guess you like

Origin www.cnblogs.com/helloNico/p/12177869.html