Skip to main content

Delete User

As Master Controller provides the functionality to add multiple users, it also provides the mechanism to delete the unwanted users or the users you want to delete. For deletion of the users there must be one or more activated users existing on your device. Deletion of the user uses the events described in the delete user events list. Note that the delete user process can only be performed if the user that is to be deleted is not logged in. The user needs to trigger a DeleteUserEvent, for the details of the deletion process see this event flow:

DeleteUser event flow-diagram

iOS/Swift

For Swift you can trigger that by this snippet:

Triggering DeleteUserEvent (Swift)
public func triggerDeleteUserEvent(userIdentifier: KsUserIdentifier) {
let deleteUser = KSMDeleteUserEvent(userIdentifier: userIdentifier)
masterControllerAdapter.sendEvent2MasterController(deleteUser) { event in
Logger.sharedLogger.logInfo(content: "\(1234) receive event in callback: \(type(of: event))",
context: "\(type(of: self)).\(#function)")
}
}

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 DeleteUserEvent (Kotlin)
fun triggerDeleteUserEvent(userIdentifier: UserIdentifier) {
val deleteUserEvent = DeleteUserEvent(userIdentifier)
launchIO {
mcEventHandler?.postEvent(deleteUserEvent)?.then {
// handle result
}
}
}

All Platforms

As response to DeleteUserEvent the Master Controller sends a DeleteUserResultEvent with appropriate status, sdkState and a userList containing the remaining users.