Native inject global function into browser:
- iOS: window.webkit.messageHandlers.nativeApp.postMessage
- Android: window.nativeApp.sendToNative
Web define two methods to window:
- window.webApp.callback
- window.webApp.dispatch
by using npm:
$ npm install @0x0006e/hybrid-js-sdk
or by using yarn:
$ yarn add @0x0006e/hybrid-js-sdk
- Web dispatch
event
to native
hybrid.dispatch(event, params).then(console.log);
- Web handle native dispatch
event
const unsubscribe1 = hybrid.listen(event, callback);
const unsubscribe2 = hybrid.listen(event, callback);
- unsubscribe
event
unsubscribe1()
- Native dispatch
event
to web
webApp.dispatch(event, params);
- Native handle web dispatch
event
setTimeout(() => {
webApp.callBack(eventId, params);
});
git clone https://github.com/0x0006e/Hybrid-JS-SDK.git
cd Hybrid-JS-SDK/examples
yarn && yarn start
- tests
- PR thanks!