Delete User
As Master Controller provides the functionality to add multiple users, it also provides the mechanism to delete them. For deletion, there must be one or more activated users on your device. Deletion of a user uses the events described in the delete user events list. Note that the delete user process can only be performed if the user to be deleted is not logged in. The application needs to trigger a DeleteUserEvent. For details of the deletion process, see this event flow:
NOTE: Passing
UserIdentifier("", "")toDeleteUserEventwill delete all users on Digitanium/SSMS-based environments, but will do nothing on SHIFT.
DeleteUser event flow-diagram
iOS/Swift
For Swift you can trigger that by this snippet:
static func performDeleteUser(traceParent: String? = nil, deleteRequest: DeleteUserRequest, completion: @escaping (ActionResult) -> Void) {
let userIdentifier = KsUserIdentifier(tenantId: deleteRequest.tenant, userId: deleteRequest.userId)
let event = KSMDeleteUserEvent(userIdentifier: userIdentifier)
if let traceParent {
let state = event.traceContext.traceState
event.traceContext = .init(traceParent: traceParent, traceState: state)
}
let time = CallTimer(event: event)
MasterControllerAdapter.sharedInstance.masterController?.receive(event, withCompletionHandler: { resultEvent in
let duration = time.stop()
if let deleteUserResult = resultEvent as? KSMDeleteUserResultEvent {
let eventResult = handleDeleteStatus(status: deleteUserResult.status, duration: duration)
let actionResult = ActionResult(title: "deleteUserModel.status.title".localized(table: localizedTable),
success: eventResult.success,
error: eventResult.errorText?.localized(table: localizedTable),
duration: duration,
event: resultEvent)
EventLogObject(actionResult: actionResult,
component: "\(self)")
completion(actionResult)
}
})
}
Android/Kotlin
fun triggerDeleteUserEvent(userIdentifier: UserIdentifier) {
synchronousEventHandler.postEvent(DeleteUserEvent(userIdentifier))?.then {
// handle result
}
}
All Platforms
As a response to DeleteUserEvent, the Master Controller sends a DeleteUserResultEvent with appropriate status, sdkState, and an array of UserDetails containing the remaining users.
⚠️ Deprecated: The array of
UserIdentifierinDeleteUserResultEventis deprecated and will be removed in a 2026 major release. Use the array ofUserDetailsinstead. For details on theUserDetailstype, see Start/Restart Event.