This package is the Community plan edition of the client for UI integration applications.
Install the package in your project directory with:
yarn add @wildix/xbees-connect
npm install @wildix/xbees-connect
import Client from "@wildix/xbees-connect";
const xBeesClient = Client.getInstance();
console.log(xBeesClient.version());
Sends the signal to x-bees that iFrame is ready to be shown. iFrame should send it when the application starts and is ready.
Sends the message to x-bees that the user is authorized and no more actions are required.
Sends the message to x-bees that user actions are required:
onSuggestContacts: ((query: string, resolve: Resolve, reject: Reject) => void) => RemoveEventListener
Starts listen for the events of searching contacts and handle autosuggestion with the provided callback */
Client.getInstance().onSuggestContacts(async (query, resolve) => {
try {
const contacts = await fetchContacts(query);
resolve(contacts);
} catch (error) {
console.log('catch', error);
}
});
onLookupAndMatchContact: ((query: ContactQuery, resolve: Resolve, reject: Reject) => void) => RemoveEventListener
Starts listen for the events of searching contact info and handle match with the provided callback
Client.getInstance().onLookupAndMatchContact(async (query, resolve) => {
try {
const contact = await fetchContactAndMatch(query);
resolve(contact);
} catch (error) {
console.log('catch', error);
}
});
Retrieves current x-bees context data. The data may be different depending on context.
Retrieves contact data currently opened in x-bees.
Retrieves conversation data ({id, type}) currently opened in x-bees. If the conversation is temporary - retrieves undefined
Retrieves current theme mode (light or dark)
Retrieves current theme mode and theme options
Starts to listen for the events of changing theme and returns the provided callback
Starts to listen for the events of changing PBX token and returns the provided callback
Starts to listen for the events of starting the call and returns the provided callback
Starts to listen for the events of ending the call and returns the provided callback
Removes particular callback from handling events
Retrieves the version of xBeesConnect
Sends a request to x-bees to start a call with a number
Sends a request to x-bees to restart the iFrame, reload with actual parameters and token
Sends a request to x-bees about changes of the current frame size
Sends a request to x-bees to put a string to the user's clipboard
Starts listening for one of the x-bees events and returns the provided callback
Stops listening for one of the x-bees events with the particular callback
Starts listen on logout event and send event to the xbees about logout able
Sends analytics data to xbees for track into analytics data
The below function can fix cases when String.replaceAll()
does not work in the mobile version. Most likely, this is some kind of WebView bug.
function replaceAll(str: string, search: string, replace: string) {
return str.split(search).join(replace);
}