Manage enrolled accounts
This topic explains how to manage the accounts enrolled in the SecureAuth Mobile SDK.
In this part of the workflow, you will set up access to accounts so you can update, invalidate, or delete an account.
Use the following code to create the AccountsViewModel
class.
// Create an AccountsViewModel to use in your accounts view controller let accountsViewModel = AccountsViewModel(secureAuth.accountStore) // Load accounts to viewModel accountsViewModel.loadAccounts() // Return accounts array accountsViewModel.accounts // Delete accounts, pass an account array with accounts that need to be deleted accountsViewModel.removeAccounts([Account]()) .subscribe(onCompleted: { // Update your UI once accounts have been deleted }) .disposed(by: disposeBag) // Retrieve account from specific index var account = accountsViewModel.accountAt(Int) // Update account name account.name = "newName" // Replace newName with the new name for the account // Invalidate account account.invalidate() // Remember to call saveAccounts after any account changes have been made accountsViewModel.saveAccounts() .subscribe(onError: { error in // Handle error appropriately }) .disposed(by: disposeBag)
where:
account.name = "newName"
Replace "newName" with the new name for the account.
Update account: Account names don't have to be unique because each account has a unique enrollment code as the identifier.
Invalidate account: An invalidated account must be enrolled again to reinstate it.
Delete account: The account is deleted from the device. The end user enrollment associated with the deleted device will exist in Active Directory, Azure AD, etc., but the device will no longer receive push notifications unless the end user enrolls again.