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 AddUserWithTokenEvent.
AddUser event flow-diagram
This diagram shows the add user with token flow.
iOS/Swift
Below is the code snippet for Swift to trigger the add user with token process:
func addUserWithToken(user: String, tenant: String, token: String, autoLogin: Bool) {
let identifier = KsUserIdentifier(tenantId: tenant, userId: user)
let event = KSMAddUserWithTokenEvent(userIdentifier: identifier, token: token, enableAutoLogin: autoLogin)
MasterControllerAdapter.sharedInstance.sendEvent2MasterController(event: event) { event in
if let addUserResult = event as? KSMAddUserResultEvent {
print(addUserResult)
}
}
}
Android/Kotlin
In Kotlin you can use below the code snippet for triggering AddUserWithTokenEvent:
fun triggerAddUserWithTokenEvent(
userIdentifier: UserIdentifier,
token: String,
autoLogin: Boolean
) {
val addUserWithTokenEvent = AddUserWithTokenEvent(userIdentifier, token, autoLogin)
launchIO {
mcEventHandler?.postEvent(addUserWithTokenEvent)?.then {
// handle result
}
}
}
All platforms
As response of this event, Master Controller provides AddUserResultEvent, or a LoginResultEvent if you used autoLogin=true when triggering AddUserWithTokenEvent. Overall the flow is similar to the activation with token flow. You can find the possible status codes of AddUserResultEvent here.