# Set up a custom consent solution

> Implement a custom developer consent solution, whether you’re using a third-party mediator or mediating with Unity Ads exclusively.

The Unity Ads Privacy API provides three methods for communicating user privacy preferences:

| Purpose                                | API method           |
| -------------------------------------- | -------------------- |
| Opt-in consent                         | `setUserConsent()`   |
| Opt-out signal                         | `setUserOptOut()`    |
| Child-directed or non-behavioral users | `setNonBehavioral()` |

> **Important:**
>
> As of SDK version 4.18.0, the UnityAds Privacy API enforces one authoritative signal per privacy framework, either the opt-in consent signal for opt-in privacy frameworks or the opt-out signal for opt-out privacy frameworks. Please consult [Supported privacy frameworks](/ads-android/4.19.0/privacy/developer-consent/frameworks/supported-frameworks.md.md) to see which method is appropriate for which privacy framework. Signals from the non‑applicable API are not applied and the framework’s default behavior remains in effect.
>
> It’s your responsibility to ensure you have reviewed and fulfilled the prerequisites and using the latest version of the Unity Ads SDK when enabling developer consent.

For more information about the Unity Ads opt-in consent API, refer to the Unity Ads Privacy API reference for developers using [Java](/ads-android/4.19.0/sdk-integration/api/android-api.md.md), [Kotlin](/ads-android/4.19.0/sdk-integration/api/android-api.md.md), [Objective-C](/ads-ios/4.19.0/sdk-integration/api/ios-api-objc.md.md), and [Swift](/ads-ios/4.19.0/sdk-integration/api/ios-api-swift.md.md).

> **Tip:**
>
> Call these methods after initializing the SDK to ensure the correct privacy behavior takes effect from the start of the session.

## Opt-in consent API

Use the following examples to communicate whether the user has granted or declined consent for targeted advertising.

## Opt-in consent API

Use the following examples to communicate whether the user has granted or declined consent for targeted advertising.

1. **Swift**

   ```swift
   // If the user agrees to personalized ads
   UnityAds.setUserConsent(true)

   // If the user doesn't agree to personalized ads
   UnityAds.setUserConsent(false)

   ```

2. **Objective-C**

   ```objc
   // If the user agrees to personalized ads
   [UnityAds setUserConsent:YES];

   // If the user doesn't agree to personalized ads
   [UnityAds setUserConsent:NO];

   ```

## Opt-out signal API

Use the following examples to indicate whether the user has opted out of data collection under applicable privacy laws.

1. **Swift**

   ```swift
   // If the user opts in to personalized ads
   UnityAds.setUserOptOut(false)

   // If the user opts out to personalized ads
   UnityAds.setUserOptOut(true)

   ```

2. **Objective-C**

   ```objc
   // If the user opts in to personalized ads
   [UnityAds setUserOptOut:NO];

   // If the user opts out to personalized ads
   [UnityAds setUserOptOut:YES];

   ```

## Age-restricted user specification API

Use the following examples to specify whether the app or user should be treated as child-directed or non-behavioral.

1. **Swift**

   ```swift
   // If the user opts out to personalized ads
   UnityAds.setNonBehavioral(true)

   // If the user opts in to personalized ads
   UnityAds.setNonBehavioral(false)

   ```

2. **Objective-C**

   ```objc
   // If the user opts out to personalized ads
   [UnityAds setNonBehavioral:YES];

   // If the user opts in to personalized ads
   [UnityAds setNonBehavioral:NO];

   ```
