# 유저 프로필 설정

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

## 유저 속성 정보

### 시작하기 전에

유저 속성 정보를 설정하기 전에 [DFINERY 콘솔](https://console.dfinery.ai/)에 유저 프로필 속성을 생성 후 연동해 주세요. 유저 프로필 속성은 부가 설정 / 데이터 연동 / 속성 관리 / 유저 프로필 속성 목록에서 생성할 수 있습니다.

## 유의사항

* 등록되지 않은 유저 프로필, 잘못된 타입의 유저 프로필 속성이 기록될 경우, 유저 프로필은 설정되지 않습니다.
* `Array of String` 타입의 유저 프로필 속성은 최대 10개까지 생성할 수 있습니다.
* `Array of Long`, `Array of Double` 타입은 최대 5개까지 생성할 수 있습니다.
* value의 입력 개수 제한은 없으나 전체 크기는 8KB를 초과할 수 없습니다.

### 유저 속성 정보 설정

#### *setUserProfile*

{% tabs %}
{% tab title="Swift" %}
다음 메소드를 호출하여 유저 속성 정보를 설정합니다.

```swift
func set(userProfiles: [String: Any])
```

userProfiles 매개변수는 다음과 같습니다.

* `userProfiles` : 유저 속성 정보명과 값을 갖는 딕셔너리
* `key` : 유저 속성 정보 명
* `value` : 유저 속성 정보 값

**사용 예시**

```swift
Dfinery.shared().set(userProfiles: [DFUserProfile.NAME: "Jimmy",
                                    "custom_user_profile": 100])
```

{% endtab %}

{% tab title="Objective-C" %}

```objective-c
setUserProfileWithDict:(NSDictionary<NSString *,id> * _Nonnull)
```

매개변수는 다음과 같습니다.

* `Dict` : 유저 속성 정보명과 값을 갖는 딕셔너리
* `Key` : 유저 속성 정보 명
* `value` : 유저 속성 정보 값

**사용 예시**

```objective-c
[[Dfinery shared] setUserProfileWithDict:@{
    @"custom_key": @"value",
    DFUserProfile.NAME: @"Jimmy"
}];
```

{% endtab %}
{% endtabs %}

{% hint style="warning" %}
표준 속성 중 성별(df\_gender)의 경우 다음의 사전 정의된 상수를 사용해 값을 입력해주세요

* DFGender.MALE
* DFGender.FEMALE
* DFGender.NONBINARY
* DFGender.OTHER
  {% endhint %}

#### 표준 유저 속성 정보

표준 유저 속성 정보의 경우 다음과 같이 프로필명이 사전 정의된 정적 상수로 제공됩니다.

| 상수명                      | 유저 속성 정보       | 입력 값 타입                |
| ------------------------ | -------------- | ---------------------- |
| DFUserProfile.NAME       | df\_name       | String                 |
| DFUserProfile.BIRTH      | df\_birth      | String(yyyy-MM-dd)     |
| DFUserProfile.MEMBERSHIP | df\_membership | String                 |
| DFUserProfile.GENDER     | df\_gender     | DFGender.xxxxx(String) |

{% hint style="warning" %}
유저 프로필 속성 중 df\_birth(생년월일)의 경우 입력 값 타입을 yyyy-MM-dd의 String 타입으로 입력해 주세요. 예시: "1999-01-01"
{% endhint %}

### 알림 수신 동의 정보 설정하기 <a href="#consent" id="consent"></a>

알림 수신 동의 정보는 유저 프로필에 속해있으며 다양한 채널에 대한 수신 동의 정보 값을 설정할 수 있습니다.

{% hint style="danger" %}
알림 수신 동의 정보를 설정해주지 않는 경우 해당 값은 null이며, null과 true일 때 발송이 가능하고, false 일 때 발송되지 않습니다. 자세한 사항은 [이용 가이드](https://docs.dfinery.ai/user-guide/action/off-site-campaign/opt-state) 참고해주시기 바랍니다.
{% endhint %}

{% hint style="info" %}
알림 수신 동의 정보에 대한 유저 프로필은 예외적으로 DFINERY에서 서비스 생성 시 이미 자동으로 등록되어 있어 DFINERY 콘솔에서 설정하지 않아도 설정이 가능합니다.
{% endhint %}

* 지원 유형
  * key : 알림 수신 동의 유형(DFUserProfile)
  * value : `Boolean`

### 사용 예시

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

```swift
Dfinery.shared().set(userProfiles: [
    DFUserProfile.PUSH_ADS_OPTIN: true,
    DFUserProfile.PUSH_NIGHT_ADS_OPTIN: false,
])
```

{% endtab %}

{% tab title="Objective-C" %}

```objective-c
[[Dfinery shared] setUserProfileWithDict:@{
    DFUserProfile.PUSH_ADS_OPTIN: @YES,
    DFUserProfile.PUSH_NIGHT_ADS_OPTIN: @NO
}];
```

{% endtab %}
{% endtabs %}

#### 알림 수신 동의 유형 <a href="#consent-type" id="consent-type"></a>

{% hint style="warning" %}
오후 9시 부터 오전 8시 사이에는 별도의 야간 광고성 알림 동의를 받아야 광고성 알림을 전송할 수 있으므로 해당 시간에 메시지를 발송하고 싶으실 경우 `PUSH_NIGHT_ADS_OPTIN` 값을 사용하여 동의를 받아 주시기 바랍니다. (불법 스팸 방지를 위한 정보통신망법 안내서, 한국인터넷진흥원, 2020.07)
{% endhint %}

| 명칭                                   | 채널           | 설명                                |
| ------------------------------------ | ------------ | --------------------------------- |
| `DFUserProfile.PUSH_ADS_OPTIN`       | 푸시           | 푸시 채널에 대한 광고성 알림 동의               |
| `DFUserProfile.PUSH_NIGHT_ADS_OPTIN` | 푸시           | 푸시 채널에 대한 야간 광고성 알림 동의            |
| `DFUserProfile.SMS_ADS_OPTIN`        | 문자           | 문자 채널에 대한 광고성 알림 동의               |
| `DFUserProfile.KAKAO_ADS_OPTIN`      | 친구톡, 브랜드 메시지 | 카카오 친구톡과 브랜드 메시지 채널에 대한 광고성 알림 동의 |


---

# 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/ios/user-profile.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.
