MoPub

public class MoPub

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 Methods

public static boolean /canCollectPersonalInformation()

  • Description: For GDPR-applicable cases, returns a boolean indicating whether the user has provided consent for MoPub and its partners to collect and process personal data. Returns true if consent is allowed and personal information may be collected, false otherwise

  • Parameters: None.

public static void /disableViewability(ExternalViewabilitySessionManager.ViewabilityVendor vendor)

  • Description: Disables viewability tracking with Moat and IAS. Refer here for additional usage instructions.

  • Parameters:

    • vendor: the name of the viewability vendor to disable. Currently accepted values are AVID, MOAT, or ALL.

public static String /getAdapterConfigurationInfo()

  • Description: Gets an instance of the configuration manager, one of which is created for every ad network to manage its initialization and all its metadata. Returns a list of MoPub-supported networks, also available here.

  • Parameters: None.

public static MoPub.BrowserAgent /getBrowserAgent()

  • Description: Returns the browser agent. If the user’s browser experience is opened in the MoPub in-app browser, returns IN-APP; if it’s opened in the device’s native browser, returns NATIVE. When a user clicks on a link within an ad, by default we open the landing page in the MoPub in-app browser; however, the click-through URL can be configured to use the click-destination scheme to open in the device’s native browser. Learn more here.

  • Parameters: None.

public static MoPub.LocationAwareness /getLocationAwareness()

  • Description: Location awareness provides additional GPS data to MoPub, enabling more precise targeting of ads. By default, the MoPub SDK collects latitude and longitude. Returns NORMAL (for maximum location disclosure), TRUNCATED (for high-level location disclosure whose precision you can customize), or DISABLED (publisher does not wish to disclose location).

  • Parameters: None.

public static int /getLocationPrecision()

  • Description: Returns the custom location disclosure (to what precision latitude and longitude are collected) when LocationAwareness is set to TRUNCATED. Location awareness provides additional GPS data to MoPub, enabling more precise targeting of ads. By default, the MoPub SDK collects latitude and longitude. Returns NORMAL (for maximum location disclosure), TRUNCATED (for high-level location disclosure whose precision you can customize), or DISABLED (publisher does not wish to disclose location).

  • Parameters: None.

public static long /getMinimumLocationRefreshTimeMillis()

  • Description: Returns a number in milliseconds corresponding to how frequently the MoPub SDK refreshes the device location. Default setting is 60000 milliseconds (60 seconds).

  • Parameters: None.

public static PersonalInfoManager /getPersonalInformationManager()

  • Description: In GDPR-applicable cases, returns an instance of the PersonalInformationManager, which manages the consent dialog.

  • Parameters: None.

public static void /initializeSdk(Context context, SdkConfiguration sdkConfiguration, SdkInitializationListener sdkInitializationListener)

  • Description: Initializes the MoPub SDK. After integrating the MoPub SDK and creating an ad unit, this method must be called before sending any ad requests. This method must be called 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 custom event 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.

  • Parameters:

    • context: Recommended to be an activity context. Rewarded ads initialization requires an Activity.
    • sdkConfiguration: Configuration data to initialize the SDK.
    • sdkInitializationListener: Callback for when SDK initialization finishes.

public static boolean /isSdkInitialized()

  • Description: Returns whether the MoPub SDK has been initialized via initializeSDK(); false otherwise..

  • Parameters: None.

public static void /resetBrowserAgent()

  • Deprecated as of 4.15.0.

public static void /setAllowLegitimateInterest(boolean allowed)

  • Description: Enables the legitimate interest flag during initialization. The MoPub SDK enables mediated networks to collect users’ personal data based on legitimate interest basis when publishers opt in. Refer to our Legitimate Interest Support documentation for more GDPR details, as well as to our integration instructions.

  • Parameters:

    • Allowed: true if legitimate interest is allowed; false otherwise.

public static void /setBrowserAgent(MoPub.BrowserAgent browserAgent)

  • Description: Specifies whether a user’s browser experience is opened in the MoPub in-app browser (IN-APP) or the device’s native browser (NATIVE). When a user clicks on a link within an ad, by default we open the landing page in the MoPub in-app browser; however, the click-through URL can be configured to use the click-destination scheme to open in the device’s native browser. Learn more here.

  • Parameters:

    • browserAgent: IN-APP for MoPub in-app browser or NATIVE for the device’s native browser.

public static void /setLocationAwareness(MoPub.LocationAwareness locationAwareness)

  • Description: Location awareness provides additional GPS data to MoPub, enabling more precise targeting of ads. By default, the MoPub SDK collects latitude and longitude. Setting to DISABLED prevents passing this data.

  • Parameters:

    • locationAwareness: NORMAL (for maximum location disclosure), TRUNCATED (for high-level location disclosure whose precision you can customize), or DISABLED (publisher does not wish to disclose location).

public static void /setLocationPrecision(int precision)

  • Description: Specifies custom location disclosure (to what precision latitude and longitude are collected) when LocationAwareness is set to TRUNCATED. Location awareness provides additional GPS data to MoPub, enabling more precise targeting of ads. By default, the MoPub SDK collects latitude and longitude.

  • Parameters:

    • locationAwareness: NORMAL (for maximum location disclosure), TRUNCATED (for high-level location disclosure whose precision you can customize), or DISABLED (you do not wish to disclose location).

public static void /setMinimumLocationRefreshTimeMillis(long minimumLocationRefreshTimeMillis)

  • Description: Specifies how frequently the MoPub SDK should refresh the device location. Default setting is 60000 milliseconds.

  • Parameters:

    • minimumLocationRefreshTimeMillis: The number of milliseconds to be used.

public static boolean /shouldAllowLegitimateInterest()

  • Description: Checks whether legitimate interest is allowed and returns true if allowed; false otherwise. The MoPub SDK enables mediated networks to collect users’ personal data based on legitimate interest basis when publishers opt in. More details here and integration details here.

  • Parameters: None.

Last updated March 03, 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.)