Javascript API
Userplane has a javascript API that is accessible after you have loaded the Userplane SDK onto your site. The javascript API can be used to manipulate behaviors and extend your user experiences in a more seamless manner on your site. The API includes a series of methods, events, and callbacks. Below we provide a summary of the the events, callbacks and links to the areas of functionality that detail the functions.
Events
Ready Event
up.api.events.READY
The ready event fires when the SDK has loaded all of its pre-requisites to run inside your site. This event fires almost immediately and represents the first time you should really interact with the API.
Example of the READY callback
/* You start by creating a function to be called when the Userplane SDK is initialized. */
onReady = function () {
/* In here you will execute all the code you wish to execute using the Community API */
}
up.addCallback(up.api.events.CONNECTED, onReady);
Connected Event
up.api.events.CONNECTED
The connected event fires when the SDK has established is connection with the messaging transport. At this point your user is connected, online and available to receive and send messages, join chat rooms and any other functionality.
Example of the READY callback
/* You start by creating a function to be called when the Userplane SDK is initialized. */
onConnected = function () {
/* In here you will execute all the code you wish to execute using the Community API */
}
up.addCallback(up.api.events.CONNECTED, onConnected);