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.
this.#initSdk()
})
}
}
SDK
The first step to perform is the initialization of the SDK:
#initSdk(): void {
const configuration = new MobbScanConfiguration()
const successCallback = () => {
console.log('✅ starting SDK')
this.#setBaseUrl()
}
const errorCallback = () => {
console.log('❌ starting SDK')
}
MobbScanAPI.initSdk(configuration, successCallback, errorCallback)
}
API URL
Next, the definition of the base URL (depending on the environment) of the MobbScan API:
#setBaseUrl(): void {
const baseUrl = 'https://gateway-stage.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.