initialize()
This function is used to initialize the SDK. It is safe to call this function twice, however we recommend only calling this function once and using other functions to update different settings if needed. There's a lot of parameters, so here's a quick list with descriptions of what is expected:
appName: This is used for identifying your experience or app in analytics. Make sure this is descriptive and representative of what your app is. An example may be something likemy-asurion-claims.appVersion: This is used for identifying the version of your experience or app in analytics. This is an optional field but is helpful for correlating events between the application and the sdk.channel:'VOICE'or'CHAT'. You should only ever need to put'CHAT'here, the voice routing is handled specially by usenvironment:'development'or'production'. Use whichever one matches your environmenttoken: TODOpushNotification: TODOuntrustedMdn: You can optionally initialize with an MDN, this will still need to be verified by our experts, but it bypasses the MDN entry pagetype:'web'or'mobile'features: TODOregisterToEvents: An event callback. You can find more information in the events guidepartner: The partner you're using (can be changed later). An example isPartner.Verizon. You can find more information in updatePartnermessagingTopic: The topic you want to initialize with (can be changed later). An example isMessagingTopic.GENERAL_CONVERSATION. You can find more information in updateMessagingTopiclanguage: The language you'll be using (can be changed later). You can find more information in updateLanguage
For a more comprehensive list of supported partners and messaging topics, click on the relevant guides linked in the parameter descriptions.
Here is the function API and some example usage:
// These are the types that the initialization uses
export type ConfigState = ImmutableConfigState & MutableConfigState;
export type ImmutableConfigState = {
appName: string;
channel: Channel;
environment: 'development' | 'production';
token?: string;
pushNotification?: PushNotificationConfig;
untrustedMdn?: string;
type?: 'web' | 'mobile';
features?: FeatureFlags;
registerToEvents?: EventListener;
};
export type MutableConfigState = {
partner: Partner;
messagingTopic: MessagingTopic;
language: Language;
};
/**
* Initializes the SDK according to the provided config. Make sure you inject the script
* before calling this method. This should only be called once in your app
* @param config
*/
export const initialize = async (config: ConfigState): Promise<void>;
// Example usage:
const someFunction = () => {
initialize({
partner: 'verizon',
appName: "DemoApp",
environment: "development",
messagingTopic: "GENERAL-CONVERSATION",
channel: "CHAT",
language: "EN-US",
});
}