> 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/flutter/user-profile.md).

# 유저 프로필 설정

유저 프로필은 DFINERY 서버에서 관리하고 있는 유저에 대한 프로필 정보입니다. 해당 정보들은 모두 선택사항이며 단말기에 저장되지 않습니다.

## 시작하기 전에 <a href="#before-you-begin" id="before-you-begin"></a>

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

## 유의사항 <a href="#precautions" id="precautions"></a>

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

## 설정하기 <a href="#configuration" id="configuration"></a>

`Dfinery.setUserProfiles()` 사용하여 유저 프로필을 설정할 수 있습니다.

### 유저 프로필 속성 <a href="#user-profile-properties" id="user-profile-properties"></a>

| 상수                         | 프로필명           | 내용      |
| -------------------------- | -------------- | ------- |
| `DFUserProfile.birth`      | df\_birth      | 유저 생일   |
| `DFUserProfile.gender`     | df\_gender     | 유저 성별   |
| `DFUserProfile.name`       | df\_name       | 유저 이름   |
| `DFUserProfile.membership` | df\_membership | 유저의 멤버쉽 |

### 메소드 설명 <a href="#method-description" id="method-description"></a>

```dart
Dfinery.setUserProfiles({required Map<String, dynamic> values})
```

* `values` : 설정할 유저 프로필. [Map](https://api.dart.dev/stable/2.19.6/dart-core/Map-class.html) 형태로 이름과 값을 입력해야 합니다. `values`는 `null`이 입력 될 수 없습니다.

```dart
final sampleDate = DateTime(2014, 5, 14);
final param = {
  DFUserProfile.name: 'william',
  DFUserProfile.gender: DFGender.male,
  'custom_user_profile_1': sampleDate,
  'custom_user_profile_2': [1,2,3],
  'custom_user_profile_3': ["a","b","c"]
};
Dfinery.setUserProfiles(values: param);
```

## 사용 예시 <a href="#usage-example" id="usage-example"></a>

유저 프로필에는 표준 키 값 들이 있으며, 키 값에 `DFUserProfile`에 있는 상수를 입력하면 적용됩니다.

### 이름 설정하기 <a href="#set-name" id="set-name"></a>

* 지원 유형
  * value : `String`

```dart
Dfinery.setUserProfiles(values: {DFUserProfile.name: "John"});
```

### 성별 설정하기 <a href="#set-gender" id="set-gender"></a>

* 지원 유형
  * value : `DFGender.male`, `DFGender.female`, `DFGender.nonBinary`, `DFGender.other`

```dart
Dfinery.setUserProfiles(values: {DFUserProfile.gender: DFGender.male});
```

### 회원 등급 설정하기 <a href="#set-membership" id="set-membership"></a>

* 지원 유형
  * value : `String`

```dart
Dfinery.setUserProfiles(values: {DFUserProfile.membership: "VIP"});
```

### 생년월일 설정하기 <a href="#set-birth" id="set-birth"></a>

* 지원 유형
  * value : `String(yyyy-MM-dd)`

{% hint style="warning" %}
DFUserProfile.birth(생년월일)의 경우 입력 값 타입을 yyyy-MM-dd의 String 타입으로 입력해 주세요. 예시: "1999-01-01"
{% endhint %}

```dart
Dfinery.setUserProfiles(values: {DFUserProfile.birth: "1999-01-01"});
```

### 알림 수신 동의 정보 설정하기 <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 : `bool`

```dart
Dfinery.setUserProfiles(values: {DFUserProfile.pushAdsOptin: true});
```

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

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

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

## 커스텀 유저 속성 설정하기 <a href="#set-custom-profile" id="set-custom-profile"></a>

커스텀 유저 속성을 설정하고 싶을 경우 [DFINERY 콘솔](https://console.dfinery.ai/)에 해당하는 유저 프로필의 커스텀 유저 속성을 생성하고 키 값으로 입력하여 설정하면 됩니다.

```dart
Dfinery.setUserProfiles(values: {"CUSTOM_USER_PROFILE": true});
```

## 날짜 및 시간 형식의 커스텀 유저 속성 설정하기 <a href="#how-to-write-date-format" id="how-to-write-date-format"></a>

날짜 및 시간 형식의 설정해야 할 경우 [DateTime](https://api.dart.dev/stable/2.19.6/dart-core/DateTime-class.html) 형태로 입력해야 합니다. 입력한 값은 TimeZone 정보를 포함하여 입력됩니다.

```dart
final sampleDate = DateTime(2014, 5, 14);
Dfinery.setUserProfiles(values: {'CUSTOM_USER_PROFILE': sampleDate});
```
