Initializing the SDK¶
When users starts the application first call that you should perform on the Onegini SDK is
OneginiClient#start method. The method is responsible for
asynchronous initialization of the SDK. During this process the SDK can return errors, for example if the device is using deprecated android version or when the
app version is outdated. Because of that the method expects a
OneginiInitializationHandler in order to return initialization results.
Please note that no other SDK methods should be called before the
start() method completes. Doing so has the potential to create race conditions that may lead
to issues such as user or device deregistration.
When the SDK is successfully initialized the
onSuccess method will be called. The
Set that is passed in the method contains profiles that were detected on
the device but removed on the Token Server side. In such case the SDK removes outdated profiles from and indicates which profiles were removed, so you can
perform additional actions if needed (for example remove additional data from your app's memory).
If something wrong happens during initialization, the SDK will call
onError method with
OneginiInitializationError object containing error details. In some
cases you might want to ignore some errors. For example some apps could ignore
OneginiInitializationError.NETWORK_CONNECTIVITY_PROBLEM error type and allow
user to perform some operations offline. On the other hand errors like
OneginiInitializationError.OUTDATED_APP should be handled as soon as possible, because
the SDK will return the same error in other calls (like
authenticateUser) as long as they are not resolved. In case
OneginiInitializationError.DEVICE_DEREGISTERED occur, you should clear local storage from device and all user's related data.
Code example OneginiClient initialization
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41