Getting started with MobbID
You must configure the sdk before using it.
Overview
MobbID allows you to register and authenticate a user using different biometric technologies: face, voice, handwritten signature, iris and fingerprint. You no longer need a user/password to access your favourite app or services.
Initialisation
The first step is always to initialise the API. You need to this before any other action or the SDK will not work. You need your license key to complete this step.
MobbIDAPI.getInstance().initAPI("yourlicense");
[[MobbIDAPI getInstance] initAPIWithLicense:@"your_license"];
Note In iOS make sure you import the umbrella headers available:
#import <MobbIDSDK-Core/MobbIDSDK-Core.h>
#import <MobbIDSDK-Face/MobbIDSDK-Face.h>
...
In case the use of modules is enabled in your app, instead of importing umbrella headers you would rather import the modules this way:
@import MobbIDSDK_Core;
@import MobbIDSDK_Face;
They contain all needed classes to interact with the SDK.
// Use a property or create an instance when you need it
IXMobbIDAPI mobbIdApi;
...
mobbIdApi = DependencyService.Get<IXMobbIDAPI>();
mobbIdApi.InitApiWithLicense("SET_UP_YOUR_LICENSE");
Tip: Make sure to be using the MobbIDSDK package
using MobbIDSDK;
Warning: Due to some issue (iOS dependencies in libraries are not always resolved until you instance a class explicitly) you will need to add an interface in your app and implement in both platforms. Because of that you will need to follow these extra steps:
- Within the shared module, create a new interface named
IMobbIDSDKInitializer
and define this method:
namespace MobbIDSimple
{
public interface IMobbIDSDKInitializer
{
void Init();
}
}
- Within iOS module: create a new class named
MobbIDSDKInitializer
that implements the interface you just created and copy the following code:
using MobbIDSimple.iOS;
using Xamarin.Forms;
[assembly: Dependency(typeof(MobbIDSDKInitializer))]
namespace MobbIDSimple.iOS
{
public class MobbIDSDKInitializer : IMobbIDSDKInitializer
{
void IMobbIDSDKInitializer.Init() => new MobbIDSDK.iOS.XMobbIDAPI();
}
}
- Within Android module: create a new class to implement the interface and copy this code:
using MobbIDSimple.Droid;
using Xamarin.Forms;
[assembly: Dependency(typeof(MobbIDSDKInitializer))]
namespace MobbIDSimple.Droid
{
public class MobbIDSDKInitializer : IMobbIDSDKInitializer
{
void IMobbIDSDKInitializer.Init()
{
// Nothing required to be done
}
}
}
As you may noticed, the Android implementation does not any work but it is necessary to implement the interfaces in all platforms in order to get your project compiling.
- Once you finish the previous steps, invoke the
init()
method in the app entry point to make sure the issue is solved at the very beginning. Locate yourApp.xaml.cs
and add the following line right after the component initialisation:
public partial class App : Application
{
public App()
{
InitializeComponent();
DependencyService.Get<IMobbIDSDKInitializer>().Init();
...
}
...
}
Customising the SDK
Now you can set up the SDK based on your specific needs.
MobbID SDK can work both in online or offline modes. Online mode does most of the hard work on the server side and return the results, whereas in offline mode everything is done inside the device and the captured data (face, voice, etc) does not leave the device.
By default, MobbID SDK is configured to work online. To change this behaviour:
// Set the SDK in the desired mode (OFFLINE or ONLINE)
MobbIDAPI.getInstance().setApiMode(MobbIDAPI.MobbIDAPIMode.OFFLINE);
// Set the SDK in the desired mode (MobbIDAPIMode_OFFLINE or MobbIDAPIMode_ONLINE)
[[MobbIDAPI getInstance] setApiMode:MobbIDAPIMode_OFFLINE];
// Set the SDK in the desired mode (XMobbIDAPIMode.Offline or XMobbIDAPIMode.Online)
mobbIdApi.ApiMode = XMobbIDAPIMode.Offline;
When you are using the online mode, you can configure the URL of the MobbID backend. Default value is https://mobbid.mobbeel.com
. To point to your own backend:
// Change the url of the server to point to
MobbIDAPI.getInstance().setBaseUrl("https://yourmobbidinstance.yourcompany.com");
// Change the url of the server to point to
[[MobbIDAPI getInstance] setBaseURL:"https://yourmobbidinstance.yourcompany.com"];
// Change the url of the server to point to
mobbIdApi.BaseUrl = "https://yourmobbidinstance.yourcompany.com"
Note: If the SDK is configured in offline mode, all server's related settings will be ignored.
User management
Once the SDK it's ready, the first thing you should do is start creating users.
The MobbIDManagementAPI
defines all operations related to the user: creation, removal, synchronization, etc.
final MobbIDManagementAPI mobbIDManagementAPI = new MobbIDManagementAPI();
// Use a property or create an instance when you need it
@property (nonatomic, strong) MobbIDManagementAPI* mobbIDManagementAPI;
...
self.mobbIDManagementAPI = [[MobbIDManagementAPI alloc] init];
// Use a property or create an instance when you need it
IXMobbIDManagementAPI mobbIdManagementApi;
...
mobbIdManagementApi = DependencyService.Get<IXMobbIDManagementAPI>();
User creation
A user
in MobbID does not store any personal information, except the biometric information itself, and it is represented by a userId
.
The user creation process is actually split into two different steps: the initial creation and a required confirmation.
Create a user
There are several options when creating a new user (more info), here you can see how to create a default user.
mobbIDManagementAPI.createUser(new CreateUserListener() {
@Override
public void createUserFinished(MobbIDAPICreateUserResult result, String userId, String token, MobbIDAPIError errorOccurred) {
// ...
}
});
[self.mobbIDManagementAPI createUser:self];
The class invoking the createUser:
method must conform to the CreateUserDelegate
protocol.
- (void) createUserFinished:(MobbIDAPICreateUserResult)result
forUser:(NSString *)userId
token:(NSString *)token
error:(NSError *)errorOccurred {
//...
}
mobbIdManagementApi.CreateUser(userId, language, gender, this);
The class invoking the CreateUser
method must implement the IXCreateUserDelegate
interface.
void UserCreationFinished (XMobbIDCreateUserResult result, string userId, string token, IXMobbIDAPIError error)
{
// ...
}
Almost every operation of the SDK will return an specific result stating if the operation has been successful or not, some extra information and the error information (if applicable).
In this case the createUser operation will return:
- result: OK or ERROR. OK meaning the creation has been successful.
- userId: The randomly generated
userId
(UUID) that will be used from now on to identify the user. It is possible to specify you ownuserId
in the creation process (more info). - token: This token is the user's creation token and it must be used to confirm the user in the next step of the process.
- error:
null or nil
if no error happened. Specific information of the error it happened (It will include the code of the error and a detailed explanation).
Confirm a user
To confirm a previously created user:
mobbIDManagementAPI.confirmCreateUser(new ConfirmUserListener() {
@Override
public void confirmCreateUserFinished(MobbIDAPIConfirmUserResult result, String userId, MobbIDAPIError errorOccurred) {
// ...
}
}, userId, token);
[self.mobbIDManagementAPI confirmCreateUser:userId token:token delegate:self];
The class invoking the confirmCreateUser:token:delegate:
method must conform to the ConfirmUserDelegate
protocol.
- (void) confirmCreateUserFinished:(MobbIDAPIConfirmUserResult)result
forUser:(NSString *)userId
error:(NSError *)errorOccurred {
//...
}
mobbIdManagementApi.ConfirmCreateUser(userId, token, this);
The class invoking the ConfirmCreateUser
method must implement the IXConfirmUserDelegate
interface.
void ConfirmCreateUserFinished (XMobbIDConfirmUserResult result, string userId, IXMobbIDAPIError error)
{
// ...
}
If the result
is OK the user has been confirmed :) The user can now be enrolled biometrically using one of the available biometric methods.
Please refer to the user management section to find out more information about existing operations.
Biometric operations
Once you finished the user creation process you can carry on with their enrollment and their later verification.
Please refer to the biometric operations to find out more information about existing operations.