> ## Documentation Index
> Fetch the complete documentation index at: https://docs.gleap.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# React Native SDK: User identity

> Identify customers and attach user information with the Gleap React Native SDK. Follow the integration code examples.

The Gleap identify call lets you tie a user to their feedback items. It includes a unique User ID and optional meta information such as email & name.

### Identify your users

*Tags*: ReactNative

To effectively manage your contacts, we advise using `Gleap.identify()` each time a user signs in or registers. This practice ensures accurate identification of your contacts from the outset. Additionally, for scenarios where contact information needs to be updated during active usage – such as when a user subscribes to a new plan or modifies their existing data – we recommend utilizing `Gleap.updateContact()`. This method allows for seamless real-time updates to contact details.

Identify your user by calling the following method.

```javascript theme={null}
Gleap.identify("12334", {
  name: "Franzi",
  email: "franzi@gleap.ai",
  phone: "+1 (902) 123123",
  plan: "Pro plan",
  companyName: "ACME inc.",
  companyId: "19382",
  avatar: "https://.../avatar.png",
  value: 199.95,
  customData: {
    key1: "Test",
    key2: "ACME",
  },
});
```

<Info>
  When transmitting custom data, only primitive numeric and string values are supported for later use in segment filters.
  Please note that you can send only 35 custom data keys with an identify call.

  We currently only allow JSON strings, numbers and boolean values as custom data.
</Info>

<Info>
  Gleap defaults to guest sessions when feedback items get reported without
  calling the identify method first. All feedback items of an existing guest
  session are merged with the user session once you've identified it.
</Info>

### Enforce identity verification

Enforce identity verification to prevent third parties from impersonating logged-in users. [Learn how to generate the user hash](/documentation/guides/enforce-identity-verification)

```javascript theme={null}
Gleap.identifyWithUserHash(
  "12334",
  {
    name: "Franz",
    email: "franz@gleap.ai",
    phone: "+1 (902) 123123",
    plan: "Pro plan",
    companyName: "ACME inc.",
    companyId: "19382",
    avatar: "https://.../avatar.png",
    value: 199.95,
    customData: {
      key1: "Test",
      key2: "ACME",
    },
  },
  "GENERATED_USER_HASH"
);
```

[Click here](/documentation/guides/enforce-identity-verification) to learn how to generate the user hash.

### Protected conversation files

With **Require authenticated file access** ([Authenticated conversation files](/documentation/guides/authenticated-conversation-files)), conversation files can only be opened by agents and by the verified customer the conversation belongs to. The SDK (19.0.0 or newer) supports it without extra setup, as long as your app identifies the customer with the user hash (see above) **on every app start**.

A verified identify gives the session a short-lived file access token (15 minutes). The SDK keeps it in memory only, hands it to the widget and renews it automatically while the app is in use. `clearIdentity` revokes it. Guests and contacts identified without a hash see "Sign in to view" instead of the file.

#### Open emailed file links

Email replies link attachments to your customer application URL with a `gleapFile` query parameter. If that URL opens your app (for example as a universal link or App Link), pass the URL that opened the app to Gleap. Once the customer is identified with the user hash, the SDK opens the file's conversation if the customer may see it. The link alone grants no access.

<Info>
  Available from SDK v19.0.1.
</Info>

For example with React Native's `Linking` API:

```javascript theme={null}
import { Linking } from "react-native";
import Gleap from "react-native-gleapsdk";

// Link that launched the app.
const initialUrl = await Linking.getInitialURL();
if (initialUrl) {
  await Gleap.openProtectedFileFromUrl(initialUrl);
}

// Links received while the app is running.
const subscription = Linking.addEventListener("url", ({ url }) => {
  Gleap.openProtectedFileFromUrl(url);
});
```

`openProtectedFileFromUrl` returns a `Promise<boolean>`: `true` if the link carries a Gleap file reference, `false` otherwise, so you can hand other links to your own routing. Keep the parameter through your app's login flow.

### Update contact properties

To effectively manage your contacts, we advise using `Gleap.identify()` each time a user signs in or registers. This practice ensures accurate identification of your contacts from the outset. Additionally, for scenarios where contact information needs to be updated during active usage – such as when a user subscribes to a new plan or modifies their existing data – we recommend utilizing `Gleap.updateContact()`. This method allows for seamless real-time updates to contact details.

```javascript theme={null}
Gleap.updateContact({
  value: 199.95,
  plan: "Pro plan",
});
```

The updateContact method takes in the same contact parameters as the identify method. Partial updates are possible.

```javascript theme={null}
Gleap.updateContact({
  name: "Franz",
  email: "franz@gleap.ai",
  phone: "+1 (902) 123123",
  value: 199.95,
  plan: "Pro plan",
  companyId: "12398958484",
  companyName: "ACME inc.",
  avatar: "https://.../avatar.png",
  customData: {
    key1: "awesome",
    key2: true,
  },
});
```

### Clear the identity on logout

We recommend to clear the identity once the user logs out. Clearing the identity will automatically detach the current session and create a new guest session.

```js theme={null}
Gleap.clearIdentity();
```

### Get the identification status of a user

With the following method, you can get the status of the current user identity.

```js theme={null}
const isIdentified = await Gleap.isUserIdentified();
```

### Get the current user identity

With the following method, you can get the current user identity.

```js theme={null}
const identity = await Gleap.getIdentity();
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.