# Specific Actions

### **Clear consent**

Locally removes user consent, but not on the server (this will allow a new display of the CMP on the next call to `presentNotice` for example)

```swift
func clearConsent() 
```

### **Set external ids**

Allows to define additional Ids that will be taken into account when validating user consent.

```swift
func setExternalIds(externalIds: [String: String]) -> Self
```

Example:&#x20;

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

```swift
let externalsIds = ["customPersonalId": "abze43"]
appConsent.setExternalIds(externalIds: externalsIds)
```

{% endtab %}

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

```objectivec
  NSDictionary* infos = @{@"customPersonalId": @"abze43"};
  [self.appConsent setExternalIdsWithExternalIds:infos];
```

{% endtab %}
{% endtabs %}

Once save locally, you can call `saveExternalIds`  methods below to transmit the external ids.

### **Save external ids**

This method transmit all our previous externalIds saved to our servers.&#x20;

**callback-based**

```swift
func saveExternalIds(_ completion: ACTypedResultVoidHandler?)
```

Example:

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

```swift
appConsent.saveExternalIds { result in
            switch result {
                case .success:
                print("🔥 Save External Ids Successful")
            case .failure:
                print("🔥 Save External Ids Failure")
            }
        }
```

{% endtab %}

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

```objectivec
  NSDictionary* data = [self.appConsent getExternalIds];
```

{% endtab %}
{% endtabs %}

**modern concurrency**

```swift
func saveExternalIds() async -> Result<Bool, NoticeError>
```

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

```swift
let result = await appConsent.saveExternalIds()
```

{% endtab %}

{% tab title="Objective-C" %}
Not available
{% endtab %}
{% endtabs %}

### **Get external ids**

Retrieves your previously registered external ids

```swift
func getExternalIds() -> Dictionary<String, String>
```

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

```swift
let externalIds: [String: String] = appConsent.getExternalIds()
```

{% endtab %}

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

```objectivec
  NSDictionary* data = [self.appConsent getExternalIds];
```

{% endtab %}
{% endtabs %}

### Overwrite **Consent Status**

This method allows you to overwrite a given user consent based on your internal business rules.&#x20;

It requires to build a `ConsentOverride`  object that contains multiples optional properties that allows you to override consent for specific elements (purposes, specialPurposes, vendors, etc).\
\
Each property require is a list of `ConsentStatus` that is constructed with on your element Id, the consent status and the legintStatus (optional, default value: `false`)\
\
C**allback-based**

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

```swift
  let purposes = [
  ConsentStatus(id: 1, status: true),
  ConsentStatus(id: 3, status: true, legintStatus: false)
  ]
  
  let specialPurposes = [
        ConsentStatus(id: 19, status: true),
        ConsentStatus(id: 23, status: true, legintStatus: false)]
        
 let consent = ConsentOverride(
 purposes: purposes, 
 specialPurposes: specialPurposes
  )
        
 appConsent.overwriteConsent(consent: consent) { success in 
  // Success tells you whether the override consent has been applied or not
}
```

{% endtab %}

{% tab title="Objective-C" %}
**Not available**
{% endtab %}
{% endtabs %}

**Modern concurrency**<br>

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

```swift
  let purposes = [
  ConsentStatus(id: 1, status: true),
  ConsentStatus(id: 3, status: true, legintStatus: false)
  ]
  
  let specialPurposes = [
        ConsentStatus(id: 19, status: true),
        ConsentStatus(id: 23, status: true, legintStatus: false)]
        
 let consent = ConsentOverride(
 purposes: purposes, 
 specialPurposes: specialPurposes
  )
        
 await appConsent.overwriteConsent(consent: consent)
```

{% endtab %}

{% tab title="Objective-C" %}
Not available
{% endtab %}
{% endtabs %}

### **Save floating purposes**

This method allows to save a consent on a floating purpose. &#x20;

**callback-based**

```swift
func saveFloatingPurpose(data: [String: Bool], completion: ACTypedResultVoidHandler?)
```

Example:

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

```swift
appConsent.saveFloatingPurpose(data: ["customFloatingPurpose": true]) { result in}
```

{% endtab %}

{% tab title="Objective-C" %}
Not available
{% endtab %}
{% endtabs %}

**modern concurrency**

```swift
func saveFloatingPurpose(data: [String: Bool]) async -> Result<Bool, NoticeError>
```

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

```swift
let result = await appConsent.saveFloatingPurpose(data: ["customFloatingPurpose": true])
```

{% endtab %}

{% tab title="Objective-C" %}
Not available
{% endtab %}
{% endtabs %}

### **Force Accept All**

This method allows forcing acceptance of all purposes

**callback-based**

```swift
func setForceAcceptAll(completion: ACCompletionHandler?)
```

Example:

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

```swift
appConsent.setForceAcceptAll { success in }
```

{% endtab %}

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

```objectivec
[self.appConsent setForceAcceptAllWithCompletion:^(BOOL success) {}];
```

{% endtab %}
{% endtabs %}

**modern concurrency**

```swift
func setForceAcceptAll() async -> Bool
```

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

```swift
 let success = await appConsent.setForceAcceptAll()
```

{% endtab %}

{% tab title="Objective-C" %}
Not available
{% endtab %}
{% endtabs %}

### Force Deny All

This method allows forcing deny of all purposes

**callback-based**

```swift
func setForceDenyAll(completion: ACCompletionHandler?)
```

Example:

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

```swift
appConsent.setForceDenyAll { success in }
```

{% endtab %}

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

<pre class="language-objectivec"><code class="lang-objectivec"><strong>[self.appConsent setForceDenyAllWithCompletion:^(BOOL success) {}];
</strong></code></pre>

{% endtab %}
{% endtabs %}

**modern concurrency**

```swift
func setForceDenyAll() async -> Bool
```

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

```swift
 let success = await appConsent.setForceDenyAll()
```

{% endtab %}
{% endtabs %}

### Confirm whether you need to request consent again for a specific floating purpose id

**callback-based**

```swift
func isFloatingNeedUpdate(id: String, completion: ACTypedResultVoidHandler?) 
```

Example:

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

```swift
 appConsent.isFloatingNeedUpdate(id: "customFloatingPurpose") { result in }
```

{% endtab %}

{% tab title="Objective-C" %}
Not available
{% endtab %}
{% endtabs %}

**modern concurrency**

```swift
func isFloatingNeedUpdate(id: String) async -> Bool
```

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

```swift
let result = await appConsent.isFloatingNeedUpdate(id: "customFloatingPurpose")
```

{% endtab %}

{% tab title="Objective-C" %}
Not available
{% endtab %}
{% endtabs %}
