0.0.23 • Published 5 years ago
interactive-js-bridge v0.0.23
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 5000ms4. 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
| Name | implement by InteractiveBridge | implement by container |
|---|---|---|
| setTitle | true | |
| addNotifyListener | true | |
| removeNotifyListener | true | |
| postNotification | true | |
| checkSystemPermissions | true | |
| requestSystemPermissions | true | |
| uploadContact | true | |
| getContact | true | |
| share | true | true |
| triggerUploadSteps | true | |
| pushWindow | true | |
| popWindow | true | |
| getDeviceId | true | |
| getUserId | true | |
| rpc | true | |
| getMessages | true | |
| markMessagesRead | true | |
| markAllMessagesRead | true | |
| getUnreadMessagesInfo | true | |
| $on | ||
| $off | ||
| $once |
0.0.23
5 years ago
0.0.22
5 years ago
0.0.21
5 years ago
0.0.20
5 years ago
0.0.18
6 years ago
0.0.19
6 years ago
0.0.17
6 years ago
0.0.16
6 years ago
0.0.15
6 years ago
0.0.14
6 years ago
0.0.13
6 years ago
0.0.12
6 years ago
0.0.10
6 years ago
0.0.7
6 years ago
0.0.6
6 years ago
0.0.5
6 years ago
0.0.4
6 years ago
0.0.3
6 years ago
0.0.2
6 years ago
0.0.1
6 years ago