MoPub /3.3.0

@interface MoPub : NSObject

A collection of methods that apply to the SDK as a whole. Currently, publishers can use this class to initialize the SDK, specify location-tracking preferences and its precision, set the browser agent, and address GDPR specifics.

Public Properties

BOOL/locationUpdatesEnabled /+4.9.0

  • Description: A Boolean value indicating whether the MoPub SDK should use Core Location APIs to automatically derive targeting information for location-based ads. When set to NO, the SDK will not attempt to determine device location. When set to YES, the SDK will periodically try to listen for location updates in order to request location-based ads. This only occurs if location services are enabled and the user has already authorized the use of location services for the application. The default value is YES. If a user is in General Data Protection Regulation (GDPR) region and MoPub doesn’t obtain consent from the user for using their personal data, locationUpdatesEnabled will always be set to NO. Returns a Boolean value indicating whether the SDK should listen for location updates.

  • Declaration:

    @property (assign, readwrite, nonatomic) BOOL /locationUpdatesEnabled;`
    

BOOL/frequencyCappingIdUsageEnabled /+4.9.0

  • Description: Returns a Boolean value indicating whether the MoPub SDK should create a MoPub ID that can be used for frequency capping when Limit ad tracking (for iOS 13 and lower) is on, or “Allow Apps to request to track” is disabled (for iOS14 and higher) and the IDFA we get is 00000000-0000-0000-0000-000000000000. When set to NO, the SDK will not create a MoPub ID in the above case. When set to YES, the SDK will generate a MoPub ID. The default value is YES.

  • Declaration:

    @property (assign, readwrite, nonatomic) BOOL frequencyCappingIdUsageEnabled;`
    

BOOL/isSdkInitialized /+5.0.0

  • Description: A boolean value indicating if the SDK has been initialized. This property’s value is YES if initializeSdkWithConfiguration:completion: has been called and completed; the value is NO otherwise.

  • Declaration:

    @property (readonly, nonatomic) BOOL isSdkInitialized;`
    

BOOL /canCollectPersonalInfo /+5.0.0

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

  • Declaration:

    @property (nonatomic, readonly) BOOL canCollectPersonalInfo;
    

MPConsentStatus /currentConsentStatus /+5.0.0

  • Description: Gives the current consent status of this user.NSNotification with name kMPConsentChangedNotification can be listened for to be informed of changes in the currentConsentStatus value. See MPConsentChangedNotification for more information on this notification.

  • Declaration:

    @property (nonatomic, readonly) MPConsentStatus currentConsentStatus;
    

MPBool /isGDPRApplicable /+5.0.0

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

  • Declaration:

    @property (nonatomic, readonly) MPBool isGDPRApplicable;
    

BOOL /allowLegitimateInterest /+5.5.0

  • 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 /isConsentDialogReady /+5.0.0

  • Description: Returns YES if a consent dialog is presently loaded and ready to be shown; NO otherwise.

  • Declaration:

    @property (nonatomic, readonly) BOOL isConsentDialogReady;
    

BOOL /shouldShowConsentDialog /+5.0.0

  • Description: Flag indicating that consent needs to be acquired (or reacquired) by the user, and that the consent dialog may need to be shown. This flag can be used for publishers that require use of MoPub’s consent dialog, as well as publishers that specify their own consent interface.

  • Declaration:

    @property (nonatomic, readonly) BOOL shouldShowConsentDialog;
    

NSString /currentConsentIabVendorListFormat /+5.0.0

  • Description: Current IAB format vendor list.

  • Declaration:

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

NSString /currentConsentPrivacyPolicyVersion /+5.0.0

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

  • Declaration:

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

NSString /currentConsentVendorListVersion /+5.0.0

  • Description: Current version of the vendor list.

  • Declaration:

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

NSString /previouslyConsentedIabVendorListFormat /+5.0.0

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

  • Declaration:

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

NSString /previouslyConsentedPrivacyPolicyVersion /+5.0.0

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

  • Declaration:

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

NSString /previouslyConsentedVendorListVersion /+5.0.0

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

  • Declaration:

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

Public Methods

+/sharedInstance /+5.0.0

  • Description: Returns the MoPub singleton object.

  • Declaration:

    + (MoPub *_Nonnull)sharedInstance;`
    
  • Parameters: None.

-/initializeSdkWithConfiguration:completion: /+5.0.0

  • Description: Initializes the MoPub SDK asynchronously on a background thread. After you have integrated the MoPub SDK and created an ad unit, you must call this method before you send any ad requests. Call this method with any valid ad unit once per app’s lifecycle, typically on app launch. Initialization is required for several functions, including: GDPR consent mechanisms, rewarded video pre-initialization, mediation SDKs initialization, logging, Advanced Bidding, and legitimate interest. This method runs the rewarded video mediation adapter initialization any number of times, but the SDK itself can only be initialized once, and the rewarded ads module can only be initialized once. Learn more here. This should be called from the app’s application:didFinishLaunchingWithOptions: method.

  • Declaration:

    - (void)initializeSdkWithConfiguration: (MPMoPubConfiguration *_Nonnull)configuration completion:(void (^_Nullable)(void))completionBlock;

  • Parameters:

    • configuration: Required SDK configuration options.
    • completionBlock: Optional completion block that will be called when initialization has completed.

-/globalMediationSettingsForClass: /+3.5.0

  • Description: Retrieves the global mediation settings for a given class type.

  • Declaration:

    - (id<MPMediationSettingsProtocol> _Nullable)globalMediationSettingsForClass:
      (nonnull Class)aClass;`
    
  • Parameters:

    • aClass: The type of mediation settings object you want to receive from the collection.

-/setClickthroughDisplayAgentType: /+4.15.0

  • Description: Specifies whether HTTP/HTTPS click-through URLs open in the native Safari browser or in SafariViewController.

  • Declaration:

    - (void)setClickthroughDisplayAgentType:(MOPUBDisplayAgentType)displayAgentType;`
    
  • Parameters:

    • displayAgentType: If displayType is set to MOPUBDisplayAgentTypeNativeSafari = 1, HTTP/HTTPS click-through URLs are opened in the native Safari browser. If displayType is set to MOPUBDisplayAgentTypeSafariViewController = 2, HTTP/HTTPS click-through URLs are opened in SafariViewController. Default is MOPUBDisplayAgentTypeInApp = 0.

-/disableViewability:/+4.16.0-5.13.0

  • Description: Deprecated in v5.13.0 of the MoPub SDK as Moat and IAS viewability SDKs have been removed. Use disableViewability if you are using v5.14.0 of the MoPub SDK.

    Disables viewability measurement via the specified vendor(s) for the rest of the app session. A given vendor cannot be re-enabled after being disabled.

  • Declaration:

    - (void)disableViewability:(MPViewabilityOption)vendors;
    
  • Parameters:

    • vendors: The viewability vendor(s) to be disabled. This is a bitmask value; ORing vendors together is okay.

-/disableViewability/+5.14.0

  • Description: Disables viewability measurement for the rest of the app session.

  • Declaration:

    - (void)disableViewability;
    
  • Parameters: None.

-/setEngineInformation: /+5.8.0

  • Description: Sets the engine that is using this MoPub SDK.

  • Declaration:

    - (void)setEngineInformation:(nonnull MPEngineInfo *)info;`
    
  • Parameters:

    • info: Engine information.

Mediation Methods

- /adapterConfigurationNamed: /+5.5.0

  • Description: Retrieves the adapter configuration for the specified class. Returns the adapter configuration if available; otherwise nil.

  • Declaration:

    - (id<MPAdapterConfiguration> _Nullable)adapterConfigurationNamed:(NSString *)className;
    
  • Parameters:

    • className: The classname of the adapter configuration instance to retrieve.

- /availableAdapterClassNames /+5.6.0

  • Description: Retrieves the available adapter configuration class names.

  • Declaration:

    - (NSArray<NSString *> * _Nullable)availableAdapterClassNames;
    
  • Parameters: None.

- /clearCachedNetworks; /+5.0.0

  • Description: Clears all currently cached mediated networks.

  • Declaration:

    - (void)clearCachedNetworks;
    
  • Parameters: None.

- /forceGDPRApplicable; /+5.1.0

  • Description: When called, isGDPRApplicable will always be set to MPBoolYes, and GDPR will apply to this user regardless of any other conditions. This property’s value is persisted for the lifetime of the app and cannot be unset.

  • Declaration:

    - (void)forceGDPRApplicable;
    
  • Parameters: None.

- /loadConsentDialogWithCompletion: /+5.0.0

  • Description: Attempts to load a consent dialog. The completion callback method is called when either the consent dialog has finished loading or has failed to load. If there was an error, the error parameter will be non-nil.

  • Declaration:

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

- /showConsentDialogFromViewController: /+5.0.0

  • Description: If a consent dialog is currently loaded, this method will present it modally on top of viewController. If no consent dialog is loaded, this method will do nothing. didShow is called upon successful presentation of the consent dialog; otherwise it is not called. didDismiss is called after the dismissal of the consent dialog; otherwise (including if the dialog failed to present) it is not called.

  • Declaration:

    - (void)showConsentDialogFromViewController:(UIViewController *)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.

- /showConsentDialogFromViewController: /+5.0.0

  • Description: If a consent dialog is currently loaded, this method will present it modally on top of viewController. If no consent dialog is loaded, this method will do nothing. The completion callback method is called upon successful presentation of the consent dialog; otherwise it is not called.

  • Declaration:

    - (void)showConsentDialogFromViewController:(UIViewController *)viewController completion:(void (^ _Nullable)(void))completion;
    
  • Parameters:

    • viewController: The view controller that presents the consent dialog.

Publishers must have explicit permission from MoPub to use their own consent interface.

- /currentConsentPrivacyPolicyUrl; /+5.0.0

  • 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)currentConsentPrivacyPolicyUrl;
    
  • Parameters: None.

- /currentConsentPrivacyPolicyUrlWithISOLanguageCode: /+5.0.0

  • 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)currentConsentPrivacyPolicyUrlWithISOLanguageCode:(NSString * _Nonnull)isoLanguageCode;
    
  • Parameters:

    • isoLanguageCode: ISO 630-1 language code.

- /currentConsentVendorListUrl; /+5.0.0

  • 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)currentConsentVendorListUrl;
    
  • Parameters: None.

- /currentConsentVendorListUrlWithISOLanguageCode: /+5.0.0

  • 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)currentConsentVendorListUrlWithISOLanguageCode:(NSString * _Nonnull)isoLanguageCode;
    
  • Parameters:

    • isoLanguageCode: ISO 630-1 language code.

- /grantConsent; /+5.0.0

  • Description: Grants consent on behalf of the current user. If you do not have permission from MoPub to use a custom consent interface, this method will always fail to grant consent.

  • Declaration:

    - (void)grantConsent;
    
  • Parameters: None.

- /revokeConsent; /+5.0.0

  • Description: Revokes consent on behalf of the current user.

  • Declaration:

    - (void)revokeConsent;
    
  • Parameters: None.

Last updated October 06, 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.)