Multidevice (beta)
Enable users to have more than one device associated with the same Keyless account.

Prerequisites

Let's call the device you want to add the "new device" and any device already enrolled in the Keyless network "old device".
  • The old device must be enrolled with Keyless.
  • The new device must not be enrolled with Keyless.

Retrieve the new device data

The first step starts with the new device; the Keyless SDK will generate and encrypt the required data to add the new device to the Keyless network. In this step it is also possible to pass any additional info you want to associate to the device (similar to the withDeviceInfo method in the enrollment).
Grab the KeylessNewDeviceData object containing the new device data.
Android
iOS
1
val newDeviceData : KeylessNewDeviceData = Keyless.setupNewDevice(info = "device-info")
Copied!
1
let newDeviceData = Keyless.setupNewDevice(info: "device-info")
Copied!
You should now share the newDeviceData with your "old device". In fact, it is your "old device" that will add the "new device" to the Keyless network.

Add the new device data from your old device

The second step needs to be performed on the "old device" and it will require an authentication passing the newDeviceData.
This informs your "old device" to add your "new device" to the KeylessNetwork.
Using .addingNewDevice in the AuthenticationConfiguration will output some encrypted data: oldDeviceData. The integretor is responsible to pass this oldDeviceData to your "new device". You can see this oldDeviceData as a confirmation blob necessary to complete the new device registration.
Android
iOS
1
val configuration = AuthenticationConfiguration.builder
2
.addingNewDevice(newDeviceData = newDeviceData)
3
.build()
4
5
Keyless.authenticate(
6
authenticationConfiguration = configuration,
7
onCompletion = { result ->
8
when (result) {
9
is Keyless.KeylessResult.Success -> {
10
val oldDeviceData: KeylessOldDeviceData? = authResult.value.oldDeviceData
11
}
12
is Keyless.KeylessResult.Failure -> Log.d("KeylessSDK ", "Authentication failure - error code ${result.error.code}")
13
}
14
}
15
)
Copied!
1
let configuration = Keyless.AuthenticationConfiguration.builder
2
.addingNewDevice( newDeviceData: newDeviceData)
3
.build()
4
5
Keyless.authenticate(
6
authenticationConfiguration: configuration,
7
onCompletion: { result in
8
switch result {
9
case .success(let success):
10
print(success.token)
11
case .failure(let error):
12
break
13
}
14
})
Copied!

Confirm new device

The third and last step is performed on the "new device". Authenticating providing the oldDeviceData from the previous step will finalize the "new device" registration with the Keyless network.
Android
iOS
1
val configuration = AuthenticationConfiguration.builder
2
.confirmingNewDevice(oldDeviceData)
3
.build()
4
5
Keyless.authenticate(
6
authenticationConfiguration = configuration,
7
onCompletion = { result ->
8
when (result) {
9
is Keyless.KeylessResult.Success -> {
10
// new device added
11
}
12
is Keyless.KeylessResult.Failure -> Log.d("KeylessSDK ", "Authentication failure - error code ${result.error.code}")
13
}
14
}
15
)
Copied!
1
let configuration = Keyless.AuthenticationConfiguration.builder
2
.confirmingNewDevice(oldDeviceData)
3
.build()
4
5
Keyless.authenticate(
6
authenticationConfiguration: configuration,
7
onCompletion: { result in
8
switch result {
9
case .success(let success):
10
// new device added
11
case .failure(let error):
12
break
13
}
14
})
Copied!

Fetching devices list

With this API it is possible to get the list of the user's devices.
Android
iOS
1
Keyless.getDevicesList(
2
onCompletion = { result ->
3
when (result) {
4
is Keyless.KeylessResult.Success -> {
5
val devicesList: List<KeylessDevice>? = result.value.devicesList
6
}
7
is Keyless.KeylessResult.Failure -> Log.d("KeylessSDK ", "Error getting the devices list. Error code ${result.error.code}")
8
}
9
}
10
)
Copied!
1
Keyless.getDevicesList(
2
onCompletion: { result in
3
switch result {
4
case .success(let deviceList):
5
print("Devices list: \(devicesList)")
6
case .failure(let error):
7
break
8
}
9
})
Copied!
Keyless Device
A Keyless device is identified by an ID (a signing key) and it contains any additional info specified
  1. 1.
    during the enrollment in the withDeviceInfo method;
  2. 2.
    when adding a a new device in the setupNewDevice method;

Revoking a device

It is possible to revoke any device for a given identifier. Revoking a device will make it impossible for the user to authenticate. Devices' identifiers are returned by the Keyless.getDevicesList method.
Android
iOS
1
val configuration = AuthenticationConfiguration.builder
2
.revokingDevice(id = "device_identifier")
3
.build()
4
5
Keyless.authenticate(
6
authenticationConfiguration = configuration,
7
onCompletion = { result ->
8
when (result) {
9
is Keyless.KeylessResult.Success -> Log.d("KeylessSDK ", "Revoke device success")
10
is Keyless.KeylessResult.Failure -> Log.d("KeylessSDK ", "Revoke device - error code ${result.error.code}")
11
}
12
}
13
)
Copied!
1
let configuration = Keyless.AuthenticationConfiguration.builder
2
.revokingDevice(id: "device_id")
3
.build()
4
5
Keyless.authenticate(
6
authenticationConfiguration: configuration,
7
onCompletion: { result in
8
switch result {
9
case .success(let success):
10
print("Revoke device success")
11
case .failure(let error):
12
print("Revoke device - error: \(error)")
13
}
14
})
Copied!