> For the complete documentation index, see [llms.txt](https://docs.dfinery.ai/developer-guide/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.dfinery.ai/developer-guide/platform/android/identity.md).

# 유저 식별 정보 설정

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

## 설정하기

유저 식별 정보는`DfineryProperties.setIdentity`와 `DfineryProperties.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`  | 유저의 라인 계정 아이디  |

### 항목별로 설정하기

```java
void setIdentity(DFIdentity identity, String value)
```

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

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

```java
DfineryProperties.setIdentity(DFIdentity.EXTERNAL_ID, "IDENTITY_VALUE");
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
DfineryProperties.setIdentity(DFIdentity.EXTERNAL_ID, "IDENTITY_VALUE")
```

{% endtab %}
{% endtabs %}

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

```java
void setIdentities(Map<DFIdentity, String> values)
```

* `values` : `java.util.Map<DFIdentity, String>`의 형태로 유저 식별 정보의 종류와 값을 입력해야 합니다. `values`는 `null`이 입력될 수 없습니다.

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

```java
Map<DFIdentity, String> identities = new HashMap<>();
identities.put(DFIdentity.EXTERNAL_ID, "IDENTITY_VALUE");
identities.put(DFIdentity.EMAIL,"IDENTITY_VALUE");
identities.put(DFIdentity.PHONE_NO, "821012345678");
DfineryProperties.setIdentities(identities);
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
val identities = mapOf<DFIdentity, String>(
    DFIdentity.EXTERNAL_ID to "IDENTITY_VALUE", 
    DFIdentity.EMAIL to "IDENTITY_VALUE",
    DFIdentity.PHONE_NO to "821012345678"
)
DfineryProperties.setIdentities(identities)
```

{% endtab %}
{% endtabs %}

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

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

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

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

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

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

```java
DfineryProperties.resetIdentity();
```

{% endtab %}

{% tab title="Kotlin" %}

```java
DfineryProperties.resetIdentity()
```

{% endtab %}
{% endtabs %}

## 더 알아보기

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


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.dfinery.ai/developer-guide/platform/android/identity.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
