0.0.23 • Published 4 years ago

interactive-js-bridge v0.0.23

Weekly downloads
60
License
-
Repository
-
Last release
4 years ago

Interactive JS Bridge

1. usage:

import InteractiveJSBridge from 'interactive-js-bridge'
const bridge = InteractiveJSBridge.create()
bridge.setTitle('New Title')

2. promise:

each api call returns a promise.

If you want to handle the result of jsapi, you can do this:

import InteractiveJSBridge from 'interactive-js-bridge'
const bridge = InteractiveJSBridge.create()
bridge.getContact().then(function(result) {
    console.log(result)
})

or

import InteractiveJSBridge from 'interactive-js-bridge'
const bridge = InteractiveJSBridge.create()
const result = await bridge.getContact()
if(result && result.error) {
    // to handle error case
}

3. timeout

each api call has timeout, default to no limit.

You can change the timeout by pass another value

import InteractiveJSBridge from 'interactive-js-bridge'
const bridge = InteractiveJSBridge.create()
bridge.apiTimeout = 5000 // set timeout to 5000ms

4. api mock ability

In develop period, we don't need native app container.

To use jsapi without app, we support mock

import InteractiveJSBridge from 'interactive-js-bridge'
const bridge = InteractiveJSBridge.create(3000)
bridge.mock('getContact', function() {
    return {
        success: true,
        data: [{
           'contactNumberList':x1,
           'contactId':y1,
           'displayName':'z1',
           'deleteStatus':'0'
       }, 
       {
           'contactNumberList':x2,
           'contactId':y2,
           'displayName':'z2',
           'deleteStatus':'0'
       }]
    }
})
const result = await bridge.getContact()

We suggest you use process.env to make the mock only work in develop env

5. api list

Nameimplement by InteractiveBridgeimplement by container
setTitletrue
addNotifyListenertrue
removeNotifyListenertrue
postNotificationtrue
checkSystemPermissionstrue
requestSystemPermissionstrue
uploadContacttrue
getContacttrue
sharetruetrue
triggerUploadStepstrue
pushWindowtrue
popWindowtrue
getDeviceIdtrue
getUserIdtrue
rpctrue
getMessagestrue
markMessagesReadtrue
markAllMessagesReadtrue
getUnreadMessagesInfotrue
$on
$off
$once
0.0.23

4 years ago

0.0.22

4 years ago

0.0.21

4 years ago

0.0.20

4 years ago

0.0.18

4 years ago

0.0.19

4 years ago

0.0.17

4 years ago

0.0.16

4 years ago

0.0.15

4 years ago

0.0.14

4 years ago

0.0.13

5 years ago

0.0.12

5 years ago

0.0.10

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago