@0x0006e/hybrid-js-sdk
TypeScript icon, indicating that this package has built-in type declarations

1.0.5 • Public • Published

Hybrid JS-SDK

Core

Web -> Native

Native inject global function into browser:

  • iOS: window.webkit.messageHandlers.nativeApp.postMessage
  • Android: window.nativeApp.sendToNative

Native -> Web

Web define two methods to window:

  • window.webApp.callback
  • window.webApp.dispatch

Install & API

by using npm:

$ npm install @0x0006e/hybrid-js-sdk

or by using yarn:

$ yarn add @0x0006e/hybrid-js-sdk

Web -> Native

examples/src/index.js

  • 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 -> Web

examples/src/index.js

  • Native dispatch event to web
webApp.dispatch(event, params);
  • Native handle web dispatch event
setTimeout(() => {
  webApp.callBack(eventId, params);
});

Preview

  git clone https://github.com/0x0006e/Hybrid-JS-SDK.git
  cd Hybrid-JS-SDK/examples
  yarn && yarn start

TODO

  • [ ] tests
  • [x] workflow CI CD
  • [ ] lint

Others

  • PR thanks!

Readme

Keywords

Package Sidebar

Install

npm i @0x0006e/hybrid-js-sdk

Weekly Downloads

0

Version

1.0.5

License

ISC

Unpacked Size

15.9 kB

Total Files

25

Last publish

Collaborators

  • 0x000fe