Skip to main content

Login

Note that the SDK allows applications to support multiple user accounts in one installation. When receiving a StartResultEvent with a non-empty userList as a response to StartEvent that list might contain one or multiple users. The user then needs to choose an account by providing the desired userID and the corresponding PIN to the LoginEvent. The login flow involves these events.

Login event flow-diagram

This diagram shows the sequence of events happening during login:

User Identifier

UserIdentifier - values you can get in StartResultEvent in the userList array. Please note that you should use a combination of userId and tenantId the same as MCSDK sends in StartResultEvent. Do not use the default value of tenantId from your config files. This can cause an issue with a login since we have a multi-tenant system value of logged-in users and the default value of it can be different.

iOS/Swift

The user needs to trigger a LoginEvent with the desired user id and Pin. For Swift, you can trigger that by this snippet:

Triggering Login Event (Swift)
let loginEvent = KSMLoginEvent(
userIdentifier: userIdentifier, andPin: pin)
masterControllerAdapter.sendEvent2MasterController(
loginEvent, withCompletionHandler: nil)

Android/Kotlin

For Kotlin, we have created a dedicated method in the MCHandler class of our example app to trigger this event. Below is the code snippet:

Triggering Login Event (Kotlin)
fun triggerLoginEvent(userId: String, pin: String, tenantId: String) {
logDebug(
"triggering LoginEvent with userId => $userId, pin => $pin && tenantId => $tenantId",
"triggerLoginEvent",
TAG
)
val loginEvent = LoginEvent(UserIdentifier(tenantId, userId), pin)
launchIO {
SessionManager.getInstance(context).setStartTime(System.currentTimeMillis())
mcEventHandler?.postEvent(loginEvent)?.then {
// handle result
}
}
}

All platforms

As response of this event, Master Controller provides LoginResultEvent with the appropriate status.