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 MobbID initialization code.
});
}
}
Initializing the SDK
The first step to perform is the initialization of the SDK:
const successCallback = () => {
console.log("✅ starting SDK");
};
const errorCallback = () => {
console.log("❌ starting SDK");
};
const applicationId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
const authToken = "eyJhbG...";
const serverUrl = "https://{{ environment }}.mobbid.mobbeel.com";
MobbIdApi.initSdk(successCallback, errorCallback, applicationId, authToken, serverUrl);
successCallback and errorCallback are functions that will be called in case of success or error respectively.
Obtaining an authToken
To initialize the MobbID SDK you need an apiKey, an applicationId and a serverUrl, all three provided by Mobbeel.
Example of the API request using a cURL command:
curl -X GET "{{ serverUrl }}/api/v7/authorization" -H "accept: application/json" -H "apiKey: {{ apiKey }}" -H "applicationId: {{ applicationId }}"
Example of the API request using a fetch request:
fetch(`{{ serverUrl }}/api/v7/authorization`, {
method: "GET",
headers: {
apiKey: apiKey,
applicationId: applicationId,
},
});
The response will contain the authToken that will be used to initialize the MobbID SDK.
NOTE: It is required to obtain the authToken by making a secure request from the client's server to the Mobbeel server, in order to prevent unauthorized use of credentials. Contact the support team to obtain more information about it.
