1.0.5 • Published 4 years ago

@0x0006e/hybrid-js-sdk v1.0.5

Weekly downloads
1
License
ISC
Repository
github
Last release
4 years ago

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
  • workflow CI CD
  • lint

Others

  • PR thanks!
1.0.5

4 years ago

3.0.0

4 years ago

1.0.7

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.1.0

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

1.4.1

4 years ago

1.4.0

4 years ago

1.3.1

4 years ago

1.2.11

4 years ago

1.3.0

4 years ago

1.2.10

4 years ago

1.2.9

4 years ago

1.2.8

4 years ago

1.2.7

4 years ago

1.2.5

4 years ago

1.2.4

4 years ago