MPConsentManager

@interface MPConsentManager : NSObject

Contains methods to get GDPR-related data, such as the policy link and the vendor list link; these are helpful when publishers use their own consent mechanism. Refer to our iOS GDPR article for additional usage instructions.

Public Properties

NSString /adUnitIdUsedForConsent

  • Description: Ad unit ID sent to Ad Server as a proxy for the MoPub app ID. If a known good ad unit ID is already cached, setting this will have no effect. This should only be set by SDK initialization and must be non-nil.

  • Declaration:

    @property (nonatomic, strong, nonnull) NSString * adUnitIdUsedForConsent;
    

BOOL /allowLegitimateInterest

  • Description: This API can be used if you want to allow supported SDK networks to collect user information on the basis of legitimate interest. The default value is NO.

  • Declaration:

    @property (nonatomic, assign) BOOL allowLegitimateInterest;
    

BOOL /canCollectPersonalInfo

  • Description: Flag indicating that personally identifiable information can be collected.

  • Declaration:

    @property (nonatomic, readonly) BOOL canCollectPersonalInfo;
    

BOOL /isConsentNeeded

  • Description: Flag indicating that consent needs to be acquired (or reacquired) by the user, and that the consent dialog may need to be shown.

  • Declaration:

    @property (nonatomic, readonly) BOOL isConsentNeeded;
    

BOOL /isForcedGDPRAppliesTransition

  • Description: Flag indicating that GDPR applicability was forced and the transition should be communicated back to the server. This will only persist in memory.

  • Declaration:

    @property (nonatomic, readonly) BOOL isForcedGDPRAppliesTransition;
    

NSString /currentLanguageCode

  • Description: Retrieves the current language code.

  • Declaration:

    @property (nonatomic, copy, readonly, nonnull) NSString * currentLanguageCode;
    

BOOL /isConsentDialogLoaded

  • Description: YES if a consent dialog is currently loaded; NO otherwise.

  • Declaration:

    @property (nonatomic, readonly) BOOL isConsentDialogLoaded;
    

NSString /consentedIabVendorList

  • Description: IAB vendor list that has been consented to.

  • Declaration:

    @property (nonatomic, copy, readonly, nullable) NSString * consentedIabVendorList;
    

NSString /consentedPrivacyPolicyVersion

  • Description: MoPub privacy policy version that has been consented to.

  • Declaration:

    @property (nonatomic, copy, readonly, nullable) NSString * consentedPrivacyPolicyVersion;
    

NSString /consentedVendorListVersion

  • Description: Vendor list version that has been consented to.

  • Declaration:

    @property (nonatomic, copy, readonly, nullable) NSString * consentedVendorListVersion;
    

MPConsentStatus /currentStatus

  • Description: Current consent status.

  • Declaration:

    @property (nonatomic, readonly) MPConsentStatus currentStatus;
    

NSString /extras

  • Description: Server extras (reserved for future use).

  • Declaration:

    @property (nonatomic, copy, readonly, nullable) NSString * extras;
    

NSString /iabVendorList

  • Description: Current IAB format vendor list.

  • Declaration:

    @property (nonatomic, copy, readonly, nullable) NSString * iabVendorList;
    

NSString /iabVendorListHash

  • Description: Current IAB format vendor list hash.

  • Declaration:

    @property (nonatomic, copy, readonly, nullable) NSString * iabVendorListHash;
    

NSString /ifaForConsent

  • Description: IFA used for consent purposes only.

  • Declaration:

    @property (nonatomic, copy, readonly, nullable) NSString * ifaForConsent;
    

MPBool /isGDPRApplicable

  • Description: Flag indicating if GDPR is applicable to the user.

  • Declaration:

    @property (nonatomic, readonly) MPBool isGDPRApplicable;
    

BOOL /forceIsGDPRApplicable

  • Description: Allows a publisher to force isGDPRApplicable toYES. When this is set to YES, isGDPRApplicable will always be MPBoolYes. This property is disk-backed, so its value will persist between app sessions once it has been set. When set back to NO, the value of isGDPRApplicable determined at first app session will apply.

  • Declaration:

    @property (nonatomic, assign) BOOL forceIsGDPRApplicable;
    

BOOL /isWhitelisted

  • Description: Flag indicating that the app is whitelisted for non-user-initiated consent changes.

  • Declaration:

    @property (nonatomic, readonly) BOOL isWhitelisted;
    

NSString /lastChangedReason

  • Description: Optional description of why the consent was changed to the current value.

  • Declaration:

    @property (nonatomic, copy, readonly, nullable) NSString * lastChangedReason;
    

NSTimeInterval /lastChangedTimestampInMilliseconds

  • Description: Timestamp of the current consent status in milliseconds. If this value is zero, consent status has never changed.

  • Declaration:

    @property (nonatomic, readonly) NSTimeInterval lastChangedTimestampInMilliseconds;
    

NSString /lastSynchronizedStatus

  • Description: Consent status that was last synchronized with the server.

  • Declaration:

    @property (nonatomic, copy, readonly, nullable) NSString * lastSynchronizedStatus;
    

NSString /privacyPolicyVersion

  • Description: Current version of MoPub’s privacy policy.

  • Declaration:

    @property (nonatomic, copy, readonly, nullable) NSString * privacyPolicyVersion;
    

NSTimeInterval /syncFrequency

  • Description: The maximum frequency in seconds that the SDK is allowed to synchronize consent information.

  • Declaration:

    @property (nonatomic, readonly) NSTimeInterval syncFrequency;
    

NSString /vendorListVersion

  • Description: Current version of the vendor list.

  • Declaration:

    @property (nonatomic, copy, readonly, nullable) NSString * vendorListVersion;
    

Public Methods

- /setAdUnitIdUsedForConsent:

  • Description: Sets self.adUnitIdUsedForConsent, and caches to disk if isKnownGood is set to YES. No-op if a known good ad unit is already cached to disk.

  • Declaration:

    - (void)setAdUnitIdUsedForConsent:(NSString * _Nonnull)adUnitIdUsedForConsent isKnownGood:(BOOL)isKnownGood;
    
  • Parameters:

    • adUnitIdUsedForConsent: Ad unit ID sent to the Ad Server as a proxy for the MoPub app ID. If a known good ad unit ID is already cached, setting this will have no effect. This should only be set by SDK initialization and must be non-nil.

    • isKnownGood: Is a BOOL and should only be set to YES when the ad unit ID has been verified with the server.

- /clearAdUnitIdUsedForConsent;

  • Description: Clears self.adUnitIdUsedForConsent as well as the backing cache.

  • Declaration:

    - (void)clearAdUnitIdUsedForConsent;
    
  • Parameters: None.

+ /sharedManager;

  • Description: Singleton instance of the manager.

  • Declaration:

    + (MPConsentManager * _Nonnull)sharedManager;
    
  • Parameters: None.

- /grantConsent;

  • Description: Allows a whitelisted publisher to grant consent on the user’s behalf.

  • Declaration:

    - (void)grantConsent;
    
  • Parameters: None.

- /revokeConsent;

  • Description: Allows a publisher to explicitly deny or revoke consent on the user’s behalf.

  • Declaration:

    - (void)revokeConsent;
    
  • Parameters: None.

- /checkForDoNotTrackAndTransition;

  • Description: Checks if there is a transition from a “do not track” state to an “allowed to track” state, or from an “allowed to track” state to a “do not track” state. If detected, the appropriate consent status state change will occur locally and trigger the kMPConsentChangedNotification. This is a local update only and will require a seperate Ad Server synchronization. ReturnsYES if a transition occurred; NO otherwise.

  • Declaration:

    - (BOOL)checkForDoNotTrackAndTransition;
    
  • Parameters: None.

- /forceStatusShouldForceExplicitNo:

  • Description: This method takes in parameters (expected to be derived from a server response) which tell the SDK to force consent status to explicit no or unknown. Explicit no takes priority over unknown. It also takes in a consent change reason, and a BOOL to tell it whether to cache and broadcast.

  • Declaration:

    - (void)forceStatusShouldForceExplicitNo:(BOOL)shouldForceExplicitNo
                   shouldInvalidateConsent:(BOOL)shouldInvalidateConsent
                    shouldReacquireConsent:(BOOL)shouldReacquireConsent
              shouldForceGDPRApplicability:(BOOL)shouldForceGDPRApplies
                       consentChangeReason:(NSString * _Nullable)consentChangeReason
                   shouldBroadcast:(BOOL)shouldBroadcast;
    
  • Parameters:

    • shouldForceExplicitNo: BOOL value to tell the SDK to force consent status to explicit ‘No’.
    • shouldInvalidateConsent: BOOL value to tell the SDK to invalidate the consent received.
    • shouldReacquireConsent: BOOL value to tell the SDK to reacquire consent.
    • shouldForceGDPRApplies: BOOL value to tell the SDK whether the force GDPR is applicable.
    • consentChangeReason: String describing the reason for consent change.
    • shouldBroadcast: BOOL value to tell the SDK whether to cache the consent and broadcast.

- /synchronizeConsentWithCompletion:

  • Description: Synchronizes the current state with Ad Server and makes any state adjustments based upon the response.

  • Declaration:

    - (void)synchronizeConsentWithCompletion:(void (^ _Nonnull)(NSError * _Nullable error))completion;
    
  • Parameters:

    • completion: Synchronization completion block.

- /loadConsentDialogWithCompletion:

  • Description: Starts loading a consent dialog asynchronously. Calls the completion callback method when done with an NSError if not successful. Calls completion immediately if a consentDialog is already loaded.

  • Declaration:

    - (void)loadConsentDialogWithCompletion:(void (^ _Nullable)(NSError * _Nullable error))completion;
    
  • Parameters: None.

- /showConsentDialogFromViewController:

  • Description: If a consent dialog is loaded, this method will present it modally from the given viewController. If no consent dialog is loaded this method will do nothing. completion is called upon successful presentation; it is not called otherwise.

  • Declaration:

    - (void)showConsentDialogFromViewController:(UIViewController * _Nonnull)viewController
                                      didShow:(void (^ _Nullable)(void))didShow
                                   didDismiss:(void (^ _Nullable)(void))didDismiss;
    
  • Parameters:

    • viewController: The view controller that presents the consent dialog.
    • didShow: This is a callback closure method to indicate the dialog is shown on the screen.
    • didDismiss: This is a callback closure method to indicate the dialog is dismissed by the user.

- /privacyPolicyUrl;

  • Description: URL to the MoPub privacy policy in the device’s preferred language. If the device’s preferred language could not be determined, English will be used. Returns the privacy policy URL for the desired language if successful; nil if there is no current vendor list.

  • Declaration:

    - (NSURL * _Nullable)privacyPolicyUrl;
    
  • Parameters: None.

- /privacyPolicyUrlWithISOLanguageCode:

  • Description: URL to the MoPub privacy policy in the language of choice. Returns the privacy policy URL for the desired language if successful; nil if the language code is invalid or if there is no current vendor list.

  • Declaration:

    - (NSURL * _Nullable)privacyPolicyUrlWithISOLanguageCode:(NSString * _Nonnull)isoLanguageCode;
    
  • Parameters:

    • isoLanguageCode: ISO 630-1 language code.
    • parameter: DESCRIPTION_or_None_ABOVE_IF_NONE

- /vendorListUrl;

  • Description: Current vendor list URL in the device’s preferred language. If the device’s preferred language could not be determined, English will be used. Returns the vendor list URL for the desired language if successful; nil if there is no current vendor list.

  • Declaration:

    - (NSURL * _Nullable)vendorListUrl;
    
  • Parameters: None.

- /vendorListUrlWithISOLanguageCode:

  • Description: Current vendor list URL in the language of choice. Returns the vendor list URL for the desired language if successful; nil if the language code is invalid or if there is no current vendor list.

  • Declaration:

    - (NSURL * _Nullable)vendorListUrlWithISOLanguageCode:(NSString * _Nonnull)isoLanguageCode;
    
  • Parameters:

    • isoLanguageCode: ISO 630-1 language code.
    • parameter: DESCRIPTION_or_None_ABOVE_IF_NONE

- /handlePersonalDataOnStateChangeTo:

  • Description: Clean up personal data and add additonal logic for personal data when consent state changes.

  • Declaration:

    - (void)handlePersonalDataOnStateChangeTo:(MPConsentStatus)newStatus fromOldStatus:(MPConsentStatus)oldStatus;
    
  • Parameters:

    • newStatus: The new value of the consent status.
    • oldStatus: Previous value of the consent status.

- /storeIfa;

  • Description: Store IFA(IDFA) temporary in NSUserDefault during MoPub initialization or app foregrounding. IFA is only used for removing personal data.

  • Declaration:

    - (void)storeIfa;
    
  • Parameters: None.

- /removeIfa;

  • Description: Remove IFA from NSUserDefault.

  • Declaration:

    - (void)removeIfa;
    
  • Parameters: None.

- /checkForIfaChange;

  • Description: If IFA is changed and the status is transitioning from MPConsentStatusConsented, remove old IFA from NSUserDefault and change status to unknown.

  • Declaration:

    - (void)checkForIfaChange;
    
  • Parameters: None.

- /updateAppConversionTracking;

  • Description: App conversion request will only be fired when MoPub obtains consent.

  • Declaration:

    - (void)updateAppConversionTracking;
    
  • Parameters: None.

Last updated February 11, 2020

TWITTER, MOPUB, and the Bird logo are trademarks of Twitter, Inc. or its affiliates. All third party logos and trademarks included are the property of their respective owners.

© 2020 MoPub (a division of Twitter, Inc.)