Transmit the user consent to other SDKs

As of November 13, 2023, Ogury Choice Manager is deprecated, meaning it will no longer be supported or updated.

Consequently, no new consent notices will be delivered through Ogury Choice Manager's APIs. Therefore, it is strongly advised against using Ogury Choice Manager in new versions of applications. In case you have migrated to a new Consent Management Platform (CMP), ensure that Ogury and its partners are included as vendors.

For earlier versions of applications still using Ogury Choice Manager, the API will maintain its functionality, continuing to return consent for users who have previously responded to a consent notice. This will remain in effect until their consent expires.

There are several options to access and pass the consent signal to your partners, with a precise status on each vendor and purpose. You can get and transmit the IAB string if your vendor's SDK is able to handle it, as the IAB string contains the complete consent signal. Alternatively, you can check the list of vendors and/or purposes that were accepted by the user and transmit that specific information.

Transmit the IAB string

The consent signal is stored in a specific UserDefaults and is automatically passed to the vendors supporting the IAB Transparency and Consent Framework (TCF).

While being registered to the IAB TCF, some vendors need to explicitly receive the IAB string. Check with your vendors to ensure that they process the consent signal by themselves. Otherwise, you can use the following method to obtain and pass the IAB string:

OguryChoiceManager.shared().tcfV2.getIABConsentString()

We recommend to use this method only in the completion block of the ask andedit methods to get the updated value of the consent signal.

If there is no consent signal for a given user, this method returns an empty string as default value. In this case, you should start the vendor's SDK as if the user had not provided their consent. The consent notice will be displayed at the next ask call, and the consent status will then be updated.

Depending on the user consent choices, you may need to enable/disable some functionalities or vendor's SDK. You can check whether the user has accepted the usage of personal data for a particular vendor by calling the following method:

OguryChoiceManager.shared().tcfV2.isAccepted(vendorId)

The isAccepted method takes the following parameter:

  • a vendorId Int, uniquely identifying each vendor. As an example, the vendor id is 277 for Ogury. You can find the list of all vendor ids in the Ogury Choice Manager vendor list.

Note that you can identify yourself as a vendor if you need specific consent for some use cases involving personal data. In this case, you first need to add yourself as a vendor in the consent notice, and then use the vendor id 0 in the isAccepted method.

We recommend to use this method only in the completion block of the ask and edit methods to get the updated value.

If there is no consent signal for a given user, this method returns falseas default value. In this case, you can start the vendor's SDK as if the user had not provided their consent. The consent notice will be displayed at the next ask call and the consent status will then be updated.

Similarly to vendors, you can access consent status for each IAB purposes, and pass this signal to your vendors and your own processes accordingly. Users can consent to all purposes at once or opt-in to only a few of them.

You can check whether the user has accepted to share their data for a given purpose by calling the following method:

OguryChoiceManager.shared().tcfV2.isPurposeAccepted(purpose)

The isPurposeAccepted method takes the following parameter:

  • a OguryChoiceManagerPurpose representing a purpose. It can take one of the following values:

Purpose values

IAB purpose names

OguryChoiceManagerPurposeStoreInformation

Information storage and access

OguryChoiceManagerPurposeSelectBasicAds

Select basic ads

OguryChoiceManagerPurposeCreatePersonalisedAds

Create personalised ads

OguryChoiceManagerPurposeSelectPersonalisedAds

Select personalised ads

OguryChoiceManagerPurposeCreatePersonalisedContent

Create personalised content

OguryChoiceManagerPurposeSelectPersonalisedContent

Select personalised content

OguryChoiceManagerPurposeMeasureAdPerformance

Measure ad performance

OguryChoiceManagerPurposeMeasureContentPerformance

Measure content performance

OguryChoiceManagerPurposeMarketResearch

Market research

OguryChoiceManagerPurposeDevelopAndImproveProducts

Develop and improve products

We recommend to use this method only in the completion block of the ask and edit methods to get the updated value.

If there is no consent signal for a given user, this method returns falseas default value. In this case, you can start the vendor's SDK as if the user had not provided their consent. The consent notice will be displayed at the next ask call and the consent status will then be updated.

Transmit purpose and vendor specific status for a particular vendor

Depending on users consent choices you can check status for a particular vendor and all IAB purposes declared under Consent by that vendor to, for example enable/disable that vendor’s SDK.

You can check whether all consent based purposes declared by this vendor are accepted by the user along with the vendor itself.

OguryChoiceManager.tcfV2.isVendorAndItsPurposesAccepted(vendorId);

The isVendorAndItsPurposesAccepted method takes the following parameter:

  • a vendorId Int, uniquely identifying each vendor. As an example, the vendor id is 277 for Ogury. You can find the list of all vendor ids in the Ogury Choice Manager vendor list.

Note that you can identify yourself as a vendor if you need specific consent for some use cases involving personal data. In this case, you first need to add yourself as a vendor in the consent notice, and then use the vendorId 0 in the isVendorAndItsPurposesAccepted method.

We recommend to use this method only in the completion block of the ask and edit methods to get the updated value.

If there is no consent signal for a given user, this method returns falseas default value. In this case, you can start the vendor's SDK as if the user had not provided their consent. The consent notice will be displayed at the next ask call and the consent status will then be updated.

Integration example

Find below an example of user consent handling for several vendors.

import UIKit
import OguryChoiceManager
import OguryAds
import GoogleMobileAds

class ViewController: UIViewController {

    var interstitial: DFPInterstitial!

    override func viewDidLoad() {
        super.viewDidLoad()
        // you can initialize SDK here or in AppDelegate
        let config = OguryChoiceManagerConfig.default()
        OguryChoiceManager.shared().setup(withAssetKey: "ASSET_KEY", andConfig: config)
        
        // get user consent
        OguryChoiceManager.shared().ask(with: self) { (error, response) in
            // pass user consent to vendors' SDKs
            passConsentToOtherSdks()
            // start SDKs
            startSdks()
            // load ad formats
            loadInterstitialAd();
    }
    
    private func passConsentToOtherSdks() {
        // pass consent through IAB string
        let iabString = OguryChoiceManager.shared().getIABConsentString()
        vendorSdk.setConsentFromIABString(iabString)
        
        // check if a vendor is accepted
        let vendorAccepted = OguryChoiceManager.shared().tcfV2.isAccepted(vendorIdInt)
        anotherVendorSdk.setConsent(vendorAccepted)
        
        // check consent for yourself and for your analytics solution
        let meAccepted = OguryChoiceManager.shared().tcfV2.isAccepted(0)
        let analyticsVendorAccepted = OguryChoiceManager.shared().tcfV2.isAccepted(analyticsVendorSlugId)
        // for analytics we check the MEASUREMENT purpose
        let measurementPurposeAccepted = OguryChoiceManager.shared().tcfV2.isPurposeAccepted(.measurement)
        analyticsSdk.setConsent(meAccepted && analyticsVendorAccepted && measurementPurposeAccepted)
    }
    
    private func startSdks() {
        // [optional] start the Ogury SDK
        OguryAds.shared().setup(withAssetKey: "ASSET_KEY")
        // start vendors' SDK
        vendorSdk.start()
        anotherVendorSdk.start()
        analyticsSdk.start()
    }
    
    private func loadInterstitialAd() {
        // pass consent to the GAM SDK
        let googleAccepted = OguryChoiceManager.shared().tcfV2.isAccepted(459)
        let extras = GADExtras()
        extras.additionalParameters = ["npa": googleAccepted ? "0" : "1"]
        
        let request = DFPRequest()
        request.register(extras)
        interstitial = DFPInterstitial(adUnitID: "GAM_AD_UNIT_ID")
        interstitial.load(request)
    }
}

Last updated