# New Device Activation

## Recover from client state

Pass the client state created during the enrollment flow or via IDV Bridge to recover the account on a new device. The client state is the one you obtained and stored securely when enrolling users via IDV Bridge or the Mobile SDK on the previous sub-page

{% hint style="info" %}
When enrolling from the client state, Keyless shows the enrollment UI to users as of 5.0.1 including the live filters.
{% endhint %}

{% tabs %}
{% tab title="Android" %}

```kotlin

// clientState retrieved from previous step
val clientState = "<your_client_state>"

val enrollConfig = BiomEnrollConfig(clientState = clientState)

Keyless.enroll(
  configuration = enrollConfig,
  onCompletion = { result ->
    when (result) {
      is Keyless.KeylessResult.Success -> {

      	// account recovered
      	val userId = result.value.userId

      }
      is Keyless.KeylessResult.Failure -> Log.d("KeylessSDK ", "error code ${result.error.code}")
    }
  }
)

```

{% endtab %}

{% tab title="iOS" %}

```swift

// clientState retrieved from previous step
let clientState = "<your_client_state>"

let enrollConfig = BiomEnrollConfig(clientState: clientState)

Keyless.enroll(
  configuration: enrollConfig,
  onCompletion: { result in
    switch result {
    case .success(let enrollSuccess):
    	
    	// account recovered
      	let userId = enrollSuccess.userId

    case .failure(let error):
        print("error code: \(error.code)
    }
  })
```

{% endtab %}

{% tab title="Flutter" %}

```dart
import 'package:keyless_flutter_sdk/keyless.dart';
import 'package:keyless_flutter_sdk/models/configurations/enrollment_configuration.dart';

// temporaryState retrieved from previous step
final temporaryState = "<your_temporary_state>";

final enrollConfig = BiomEnrollConfig(temporaryState: temporaryState);

try {
    final result = await Keyless.instance.enroll(enrollConfig);
    // account recovered
    print("Account recovered successfully. UserID: ${result.keylessId}");
} catch (error) {
    print("Account recovery failed: $error");
}
```

{% endtab %}

{% tab title="React Native" %}

```typescript
const clientState = '<your client state';
const config = new BiomEnrollConfig({
  clientState: clientState,
});

const result = await Keyless.enroll(config);
result.fold({
  onSuccess(data) {
    logConsole('Enroll result success ' + JSON.stringify(data, null, 2));
  },
  onFailure(error) {
    logConsole('Enroll result failure ' + JSON.stringify(error, null, 2));
  },
});
```

{% endtab %}
{% endtabs %}

The account is recovered and it's now possible to authenticate the user with ongoing 2 factor authentication with a single
