Initialization
Introduction
First of all, the plugin will not be available until the Ionic Platform.ready() triggers:
import { Platform } from "@ionic/angular";
class SomeComponent {
constructor(private platform: Platform) {
this.platform.ready().then(() => {
// Here goes MobbScan initialization code.
});
}
}
Initializing the SDK
The first step to perform is the initialization of the SDK:
const configuration = new MobbScanConfiguration();
const successCallback = () => {
console.log('✅ starting SDK');
this.#setBaseUrl();
}
const errorCallback = () => {
console.log('❌ starting SDK');
}
MobbScanAPI.initSdk(configuration, successCallback, errorCallback);
Setting the API URL
Next, the definition of the base URL (depending on the environment) of the MobbScan API:
const baseUrl = 'https://gateway-{{ environment }}.mobbeel.com';
const successCallback = () => {
console.log('✅ setting baseUrl');
}
const errorCallback = () => {
console.log('❌ setting baseUrl');
}
MobbScanAPI.setBaseURL(baseUrl, successCallback, errorCallback);
In both methods, successCallback and errorCallback are functions that will be called in case of success or error respectively.
