init

Initializing your app or widget

To initialize the communication with the host simply call the init method on the handler object, await the result and from this point, the widget communication is ready for use.

📘

Singular init

For security reasons the SDK can be initialized only once per session.
Hence, we recommend storing the initialiazed SDK reference as a singlton so it can be acceed later from any place in your code.

SDK init example

import messageHandler from '@vcita/intandem-app-com';

const entityUid = 'YOUR_APP_CODE_NAME_OR_WIDGET_UID';  
let initialized = false;

await messageHandler.init(window.parent, window, entityUid).then(() => {  
    // The widget is ready to communicate with the host 
  	console.log('SDK Initialized!')
    initialized = true;  
}).catch((error) => {  
    // In case there is an error during initialization  
    console.log(error);  
});

Since the SDK can only be initialized once, you may want to store the messageHandler reference so that you can use it outside the promise callback.

Example:

import messageHandler from '@vcita/intandem-app-com';

const entityUid = 'YOUR_APP_CODE_NAME_OR_WIDGET_UID';  
let initialized = false;

this.intandemSDK = messageHandler;

await this.intandemSDK.init(window.parent, window, entityUid).then(() => {  
    // The widget is ready to communicate with the host
    console.log('SDK Initialized!')
    initialized = true;  
}).catch((error) => {  
    // In case there is an error during initialization  
    console.log(error);  
});

// Reference the SDK outside the callback
const user = await this.intandemSDK.getUser();