Skip to main content

Add User

Once a user has logged in to the application, then they can add a new user as a family login. Family login is a functionality that allows multiple users to log in to a single application. The Add User flow involves a set of events described in the add user events list. To start the flow, the user needs to trigger AddUserEvent.

AddUser event flow-diagram

This diagram shows the add user flow.

iOS/Swift

Below is the code snippet for Swift to trigger the add user process:

Triggering KSMAddUserEvent (Swift)
public func triggerAddActivationEvent(activateData: ActivateData){
let userIdentifier = KsUserIdentifier(tenantId: activateData.tenantId, userId: activateData.userId)
let addActivationEvent = KSMAddUserEvent(userIdentifier: userIdentifier, activationCode: activateData.activationCode, pin: activateData.pin, enableAutoLogin: activateData.enableAutologin)

masterControllerAdapter.sendEvent2MasterController(addActivationEvent) { event in
guard let newEvent = event else {
return
}
MCHandler.sharedInstance.masterControllerAdapter.receive(newEvent)
}
}

Android/Kotlin

In Kotlin you can use below the code snippet for triggering AddUserEvent:

Triggering AddUserEvent (Kotlin)
fun triggerAddUserEvent(
userIdentifier: UserIdentifier,
activationCode: String,
pin: String,
autoLogin: Boolean
) {
val addUserEvent = AddUserEvent(userIdentifier, activationCode, pin, autoLogin)
launchIO {
mcEventHandler?.postEvent(addUserEvent)?.then {
// handle result
}
}
}

All platforms

As response of this event, Master Controller provides AddUserResultEvent, or a LoginResultEvent if you used autoLogin=true when triggering AddUserEvent. Overall the flow is similar to the activation flow. You can find the possible status codes of AddUserResultEvent here.