Backup
Backups allow you to save and restore the user's Keyless account. This is useful to give the users the ability to restore their account if the app is deleted.

Retrieve backup data

After each authentication it is possible to fetch the backupData and the backupKey and push them into your backup system. It could be Google Drive, iCloud or your cloud.
The backupData and backupKey are required to restore an account with Keyless. Save the Keyless backup info in a secure data store
Android
iOS
1
val configuration = AuthenticationConfiguration.builder
2
.retrievingBackup()
3
.build()
4
5
6
Keyless.authenticate(
7
authenticationConfiguration = configuration,
8
onCompletion = { result ->
9
when (result) {
10
is Keyless.KeylessResult.Success -> {
11
// use the backup
12
val backup: KeylessBackup? = authResult.value.backup
13
}
14
is Keyless.KeylessResult.Failure -> Log.d("KeylessSDK ", "Authentication failure - error code ${result.error.code}")
15
}
16
}
17
)
Copied!
1
let backupResult = Keyless.retrieveDataForBackup()
2
switch backupResult {
3
case .success((let backupData, let backupKey)):
4
// Handle your backup system logic
5
print("Retrieve data for backup successful")
6
case .failure(let error):
7
// Handle error and display an error to the user.
8
print("Retrieve data for backup failed with error: \(error.message)")
9
}
Copied!

Restore backup data

It is possible to restore the user account providing the backupData and the backupKey to the Keyless SDK.
Android
iOS
1
val configuration = EnrollmentConfiguration.builder
2
.withBackup(
3
backupKey = backupKey,
4
backupData = backupData
5
)
6
.build()
7
8
9
Keyless.enoll(
10
enrollmentConfiguration = configuration,
11
onCompletion = { result ->
12
when (result) {
13
is Keyless.KeylessResult.Success -> Log.d("KeylessSDK ", "Enroll success - userId ${result.value.keylessId}")
14
is Keyless.KeylessResult.Failure -> Log.d("KeylessSDK ", "Enroll failure - error code ${result.error.code}")
15
}
16
})
Copied!
1
Keyless.enrollFromBackup(backupData: backupData, backupKey: backupKey) { error in
2
if let error = error {
3
print("Enrollment from backup finished with error: \(error.message)")
4
} else {
5
print("Enrollment from backup finished successfully")
6
}
7
}
Copied!
Export as PDF
Copy link