# Add a new Trusted Device

## Steps

![Adding a New Trusted Device](/files/-M4uoteieJmjnucL2sPA)

There are 3 steps that's needed to add a new Trusted Device:

1. Check if this device is a Trusted Device
2. [Show the QR Code](/sdk-reference/android/sign-in-with-device/add-a-new-trusted-device.md#step-1-show-the-qr-code-of-the-new-device) of the New Non-Trusted Device
3. [Scan the New Device's QR Code](/sdk-reference/android/sign-in-with-device/add-a-new-trusted-device.md#step-2-scanning-the-qr-code-from-a-trusted-device) using the Trusted Device

## Step 1:  Check if this device is a Trusted Device

```javascript
checkIfThisDeviceTrusted = async () => {
  var cotter = new Cotter(API_KEY_ID);
  try {
      let user = await cotter.getLoggedInUser();
      var trusted = await user.isThisDeviceTrusted();
    } catch (err) {
      console.log(err);
    }
};
```

## Step 2: Show the QR Code of the New Device

Show a QR Code in the **New Device**, this will be scanned to register this new device. To show the QR Code of the new device:

```javascript
trustThisDevice = async () => {
  var cotter = new Cotter(API_KEY_ID);
  try {
    let user = await cotter.getLoggedInUser();
    user.trustThisDevice(onSuccessTrust, onErrorTrust);
  } catch (e) {
    console.log(e);
  }
};
onSuccessTrust = () => {
  alert('Success');
};
onErrorTrust = (errmsg, err) => {
  alert(errmsg);
};

...
<Button onPress={this.trustThisDevice} title="Make Device a Trusted Device" />
```

This will open a modal with a QR Code that can be scanned from the Trusted Device.&#x20;

## Step 3: Scan the QR Code from a Trusted Device

The Trusted Device should scan the QR Code shown in the new device.

### Setup Permission to Allow Camera

Update your `Info.plist` in `ios/YourProject/Info.plist`

```markup
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>

  <!-- Add Camera Permission -->
  
  <key>NSCameraUsageDescription</key>
  <string>YOUR TEXT</string>

  <!-- … -->

</dict>
</plist>
```

#### Android

Add the permission below to your app `android/app/src/main/AndroidManifest.xml` file:

```markup
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.myawesomeapp">

  <!-- Add Camera Permission -->
  <uses-permission android:name="android.permission.CAMERA" />
  <!-- … -->

</manifest>
```

### Scan the QR Code

To open the Scanner modal:

```java
scanQRCode = async () => {
  var cotter = new Cotter(API_KEY_ID);
  try {
    let user = await cotter.getLoggedInUser();
    user.scanQRCode();
  } catch (e) {
    console.log(e);
  }
};
...
<Button onPress={this.scanQRCode} title="Add New Device" />
```

This will open a modal where the user can scan the QR Code displayed on the new device.

{% hint style="warning" %}
If you get the error **"Cannot choose between the following variants of project :react-native-camera"**:

Add the following to your`android/app/build.gradle`

```
android {
  ...
  defaultConfig {
    ...
    missingDimensionStrategy 'react-native-camera', 'general' <-- insert this line
  }
}
```

{% endhint %}

{% hint style="warning" %}
If you get the error **"Execution failed for task ':app:mergeDexDebug'"**

Add the following to your`android/app/build.gradle`

```
android {
  ...
  defaultConfig {
    ...
    multiDexEnabled true     <-- insert this line
  }
}
```

{% endhint %}

{% hint style="danger" %}
&#x20;**If you encounter the error Invalid RNPermission X. Should be one of: ()**

1. Clean up Xcode stale data with `npx react-native-clean-project --remove-iOS-build --remove-iOS-pods`
   {% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.cotter.app/sdk-reference/react-native/react-native-sdk-passwordless-login/add-a-new-trusted-device.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
