# 유저 식별 정보 설정

DFINERY SDK를 사용하여 유저 식별 정보를 설정하는 방법입니다. [SDK 연동](/developer-guide/platform/reactnative/integration.md)이 선행되어야 합니다

## 설정하기

유저 식별 정보는`Dfinery.setIdentity`와 `Dfinery.setIdentities` 메소드를 사용하여 설정이 가능합니다. 유저 식별 정보 는 `DFIdentity`에 정의되어 있으며, 정의된 값만 사용 할 수 있습니다.

{% hint style="warning" %}
`EXTERNAL_ID`의 경우 유저 식별 정보 중 유저를 구분하는 중요한 값으로 사용되므로 고정 값을 사용하는것이 권장됩니다. 개인정보가 포함되지 않도록 주의해주세요. 만약 이메일, 전화번호 등의 개인정보가 포함되는 경우에는 암호화처리를 하시는 것을 권장합니다.
{% endhint %}

### 유저 식별 정보

| 이름                         | 내용             |
| -------------------------- | -------------- |
| `DFIdentity.EXTERNAL_ID`   | 유저 ID          |
| `DFIdentity.EMAIL`         | 유저의 이메일        |
| `DFIdentity.PHONE_NO`      | 유저의 전화번호       |
| `DFIdentity.KAKAO_USER_ID` | 유저의 카카오 계정 아이디 |
| `DFIdentity.LINE_USER_ID`  | 유저의 라인 계정 아이디  |

### 항목별로 설정하기

```javascript
setIdentity(key: string, value: string)
```

* `identity` : 유저 식별 정보 키 ( DFIdentity 상수 사용)
* `value` : 유저 식별 정보 값

```javascript
Dfinery.setIdentity(DFIdentity.EXTERNAL_ID, "IDENTITY_VALUE");
```

### 한번에 여러건 설정하기

```javascript
setIdentities(values: object)
```

* `values` : [Map](https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/Map)의 형태로 유저 식별 정보의 종류와 값을 입력해야 합니다. `values`는 `null`이 입력될 수 없습니다.

```javascript
const param = {
    [DFIdentity.EXTERNAL_ID]: 'igaworks',
    [DFIdentity.EMAIL]: 'user@igaworks.com',
    [DFIdentity.PHONE_NO]: '82212345678'
};
Dfinery.setIdentities(param);
```

{% hint style="warning" %}
전화번호의 경우 다음과 같은 형식으로 입력해주시기 바랍니다. ex) 821012345678, 82212345678
{% endhint %}

## 유저 식별 정보 초기화하기

`Dfinery.resetIdentity` 메소드를 호출하면 기존 저장하고 있던 유저 식별 정보를 제거하고 초기화할 수 있습니다.

{% hint style="danger" %}
유저 식별 정보를 초기화 할 경우 기존에 이어지고 있던 이벤트 흐름이 끊기고 단말기와 유저의 연결도 끊기게 되므로 호출에 주의하여 주시기 바랍니다.

만약 그래도 호출하신다면 수집된 이벤트의 반영을 위해 API 호출 전에 반영하고자 하는 이벤트를 먼저 호출한 후 호출하여 주시기를 바랍니다.
{% endhint %}

```javascript
Dfinery.resetIdentity();
```

## 더 알아보기

유저 연동에 대한 더 자세한 내용이 필요할 경우 고급 사용 사례에 있는 [유저 연동 시나리오](/developer-guide/common/identity-scenario.md)를 참고하세요.


---

# 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.dfinery.ai/developer-guide/platform/reactnative/identity.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.
