> ## Documentation Index
> Fetch the complete documentation index at: https://developer.onetrust.com/llms.txt
> Use this file to discover all available pages before exploring further.

# OneTrust SDK Additional Helpers

OneTrust SDK Public Methods for Saving Consent and Additional use-cases

# Existing

## Saving Consent for OneTrust

Saves the consent of the application based on the interaction type passed, and triggers notifications for the same.

**Parameters:**

* `type`: The interaction type associated with the consent.
* `completion`: The completion handler that gets called once the saving is complete.

```swift
OTPublishersHeadlessSDK.shared.saveConsent(type:, completion:)
```

**Note:** Consent will not be logged to server when interaction type is preference center close.

**Note:** consent will not logged to server when there are ATT linked categories and ATT permission is not determined.

## Reset Local consent

This API will reset the local consents of the Categories, Purposes, Vendors and SDKs.

```swift
OTPublishersHeadlessSDK.shared.resetUpdatedConsent()
```

## Adding Custom Data elements for consent logging

This API appends and stores the custom data elements which will be used while logging consent.

**Parameter**:

* `dataElements`: The custom data Elements which will be used while logging consent.

```swift
OTPublishersHeadlessSDK.shared.appendCustomDataElements(dataElements:)
```

## Sending consent from Mobile/CTV SDK to Webview/Web SDK

This API retrieves the OT SDK consent string that can be injected using javascript in a webview.

```swift
OTPublishersHeadlessSDK.shared.getOTConsentJSForWebView() -> String?
```

**Note:** To avoid reconsent prompt in webview, inject this string using javascript before launching the webview.

## Fetching values for OneTrust SDK data keys

Returns the value stored in OT SDK that is associated with the passed in key.

**Parameter:**

* `key`: The key for which the value has to be returned.

```swift
OTPublishersHeadlessSDK.shared.getValue(forKey:) -> Any?
```

## Google Consent Mode Data

Public method to get Google Consent Mode status.

```swift
OTPublishersHeadlessSDK.shared.getOTGoogleConsentModeData() -> OTGoogleConsentModeDataModel
```

**Returns**:

* Retrieves the `OTGoogleConsentModeDataModel` object. Variable `otSDKStatus` will return the OneTrust SDK status and variable consentType will return consent mode of GCM consent types.

## Get Last Downloaded Location

Returns the last location where the data was last downloaded.

```swift
OTPublishersHeadlessSDK.shared.getLastDataDownloadedLocation() -> OTGeolocationModel
```

**Returns:**

* GeolocationModel containing country, state.

**Note:** If data is not downloaded yet, this method will return a default geo location.

## Get Last User Consented Location

Returns the last location where the user has last provided consent.

```swift
OTPublishersHeadlessSDK.shared.getLastUserConsentedLocation() -> OTGeolocationModel?
```

**Returns:**

* GeolocationModel containing country, state.

**Note:** If the user has not consented yet, this method will return nil.

# Deprecated

## Opt Out of Sale of Data

This API will opt-out of sale of data if the CCPA value is already initialized.

```swift
OTPublishersHeadlessSDK.shared.optOutOfSaleOfData(completion:)
```

**Parameter:**

* `completion`: The completion handler that gets called once the opt-out for sale of data is complete.

**Deprecation Message:** This method will be removed in a couple of releases. Moving forward, we will no longer be supporting updating of CCPA string via public methods.

## Opt In to Sale of Data

This API will opt-in for sale of data if the CCPA value is already initialized.

```swift
OTPublishersHeadlessSDK.shared.optIntoSaleOfData(completion:)
```

**Parameter:**

* `completion`: The completion handler that gets called once the opt-in for sale of data is complete.

**Deprecation Message:** This method will be removed in a couple of releases. Moving forward, we will no longer be supporting updating of CCPA string via public methods.