# User Profile Settings

How to set user property information using DFINERY SDK. [SDK integration](https://docs.dfinery.ai/developer-guide/en/undefined-1/ios/integration) must be done first.

### User property information <a href="#undefined" id="undefined"></a>

#### Before you start <a href="#undefined-1" id="undefined-1"></a>

Before setting user attribute information, create and link user profile attributes in the [DFINERY console](https://console.dfinery.ai/login). User profile attributes can be created in Additional Settings / Data Linkage / Attribute Management / User Profile Attribute List.

### Note <a href="#undefined-2" id="undefined-2"></a>

* If an unregistered user profile or an incorrect type of user profile attribute is recorded, the user profile will not be set.
* `Array of String` You can create up to 10 user profile properties of a type.
* `Array of Long`, `Array of Double` you can create up to 5 types.
* There is no limit to the number of values ​​entered, but the total size cannot exceed 8KB.

### Setting user property information

#### *setUserProfile*

{% tabs %}
{% tab title="Swift" %}
Set user property information by calling one of the following methods:

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

func setUserProfile(key: String, value: Any?)
```

Each parameter means:

* `userProfiles`: A dictionary with user attribute information names and values.
* `key`: User property information name
* `value`: User property information value

**Example of use**

```swift
Dfinery.shared().setUserProfile(key: DFUserProfile.GENDER, value: DFGender.MALE)
            
Dfinery.shared().setUserProfile(key: "custom_key", value: "custom_value")
            
Dfinery.shared().set(userProfiles: [DFUserProfile.NAME: "Jimmy",
                                    "custom_user_profile": 100])
```

{% endtab %}

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

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

setUserProfileForKey:(NSString * _Nonnull) value:(id _Nullable)
```

Each parameter means:

* `Dict`: A dictionary with user attribute information names and values.
* `Key`: User property information name
* `value`: User property information value

**Example of use**

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

{% endtab %}
{% endtabs %}

{% hint style="warning" %}
For the standard attribute gender (df\_gender), please enter a value using the following predefined constants.

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

**Standard user property information**

For standard user property information, the profile name is provided as a predefined static constant as follows:

<table><thead><tr><th width="154">Constant name</th><th>User property information</th><th>Input value type</th></tr></thead><tbody><tr><td>DFUserProfile.NAME</td><td>df_name</td><td>String</td></tr><tr><td>DFUserProfile.BIRTH</td><td>df_birth</td><td>String(yyyy-MM-dd)</td></tr><tr><td>DFUserProfile.MEMBERSHIP</td><td>df_membership</td><td>String</td></tr><tr><td>DFUserProfile.GENDER</td><td>df_gender</td><td>DFGender.xxxxx(String)</td></tr></tbody></table>

{% hint style="warning" %}
For the user profile attribute df\_birth (date of birth), please enter the input value type as a String type of yyyy-MM-dd. Example: "1999-01-01"
{% endhint %}

#### Set consent information for receiving notifications <a href="#consent" id="consent"></a>

Consent to receive notifications is part of the user profile and you can set consent values ​​for various channels.

{% hint style="danger" %}
If you do not set the consent information for receiving notifications, the value is null. When it is null and true, notifications can be sent, and when it is false, notifications cannot be sent. For more information, please refer to [the user guide.](https://docs.dfinery.ai/user-guide/action/off-site-campaign/opt-state)
{% endhint %}

{% hint style="info" %}
User profiles for consent to receive notifications are automatically registered when creating a service in DFINERY, so they can be set up without having to set them in the DFINERY console.
{% endhint %}

* Support Type
  * key: Notification consent type (DFUserProfile)
  * value : `Boolean`

### Example of use

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

```swift
Dfinery.shared().setUserProfile(key: DFUserProfile.PUSH_OPTIN, value: true)
Dfinery.shared().setUserProfile(key: DFUserProfile.PUSH_ADS_OPTIN, value: true)
Dfinery.shared().setUserProfile(key: DFUserProfile.PUSH_NIGHT_ADS_OPTIN, value: false)

//or

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

{% endtab %}

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

```objective-c
[[Dfinery shared] setUserProfileForKey:DFUserProfile.PUSH_OPTIN value:@YES];
[[Dfinery shared] setUserProfileForKey:DFUserProfile.PUSH_ADS_OPTIN value:@YES];
[[Dfinery shared] setUserProfileForKey:DFUserProfile.PUSH_NIGHT_ADS_OPTIN value:@NO];

//or

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

{% endtab %}
{% endtabs %}

#### Types of consent to receive notifications <a href="#consent-type" id="consent-type"></a>

{% hint style="warning" %}
Between 9 PM and 8 AM, separate nighttime advertising notification consent is required to send advertising notifications, so if you want to send messages during that time, please use the `PUSH_NIGHT_ADS_OPTIN` value to obtain consent. (Information and Communications Network Act Guide for Prevention of Illegal Spam, Korea Internet & Security Agency, July 2020)
{% endhint %}

| Designation                          | Channel     | Explanation                                                         |
| ------------------------------------ | ----------- | ------------------------------------------------------------------- |
| `DFUserProfile.PUSH_OPTIN`           | push        | Consent to receive informational notifications for push channels    |
| `DFUserProfile.PUSH_ADS_OPTIN`       | push        | Consent to receive promotional notifications for push channels      |
| `DFUserProfile.PUSH_NIGHT_ADS_OPTIN` | push        | Consent to nightly promotional notifications for push channels      |
| `DFUserProfile.SMS_ADS_OPTIN`        | message     | Consent to receive promotional notifications for text channels      |
| `DFUserProfile.KAKAO_ADS_OPTIN`      | Friend Talk | Consent to advertising notifications for Kakao Friends Talk channel |
