Client for interacting with Bigtincan Hub JavaScript Bridge 3.0
BTCA Client library. See JavaScript Bridge 3.0 documentation for available actions.
``js`
npm install btca-client --save
You can now import btca-client and optionally include a CSS reset.
`js
import BTCAClient from 'btca-client';
import 'btca-client/css/btca.css';
`
You can also use the standalone UMD build via CDN.
`html
`
Initialise a new instance of the BTCAClient.
`js`
var BTCA = new BTCAClient({
handle: 'MY_BTCA', // unqiue handle to identify BTCA
cache: false, // caches requests (useful for debugging)
disableEvents: false, // disables default events (see below)
log: false // logs actions to console
});
There are various ways to perform a JSBridge request.
`js
// define your JSBridge action
var data = {
action: 'getEntity',
params: {
entityName: 'story',
id: 123
}
};
// send with anonymous callback
BTCA.send(data, function(result, requestId, error) {
console.log(result);
});
// send with callback reference
BTCA.send(data, handleRequestResponse);
// send with btcjsapi:// schema and named jsListener callback
BTCA.send('btcjsapi://getList?entityName=story&id=123&jsListener=handleRequestResponse')
`
By default, JSBridge actions are bound to various anchor click events. If you'd like to disable this and handle it yourself you may set disableEvents: true when initialising.
- Anchor tags with mailto: are parsed and will send a sendMail action.rel=app
- Anchor tags with an absolute URL or are treated as Hub links and will send an openURL action.rel=external
- Anchor tags with an http(s) link or are treated as external links and will send an openURL action.btcjsapi://` will send the specified action.
- Anchor tags with