All Collections
Advertising and SDKs
Using the 3rd Party API : MoPub Example
Using the 3rd Party API : MoPub Example

Android and iOS example for setting up MoPub SDK using the custom 3rd party API hooks.

Hue Jacobs avatar
Written by Hue Jacobs
Updated over a week ago

This doc applies primarily to the 2.3.6 official release, it will be updated for future releases as improvements are made.  We don't expect to be breaking anything going forward.  If you implement this it SHOULD continue to work regardless of any updates made to Buildbox 2.

We've created examples for supporting the MoPub SDK as a custom network on iOS and Android.  You can use this as a guideline for adding any 3rd party SDK support. Generally speaking, a programmer will be required to use these API hooks to their fullest extent. In the near future, we will be making some further improvements to make it more accessible to non-programmers.

In both examples, you will need to set the "Banner" and/or "Interstitial" ad network to "Custom" on your UI nodes. You can do the same for "Rewarded Video" option in the appropriate places that call for a "Purchase Method".

MoPub iOS SDK Example

  1. You will need these 3 files to setup the iOS example:

2. Replace the AdIntegrator.h and AdIntegrator.mm files in your exported iOS project. You will need to edit the AdIntegrator.mm file and add your own advertising IDs. 

3. Unzip and drag/drop the MoPub SDK into your Xcode project. You should now have the ability to use interstitials, banners, and rewarded videos through the MoPub SDK.

4. You should now be ready to build to project with customer MoPub support.

MoPub Android SDK Example

1. You will need these 2 files to setup the Android example:

2. Replace the AdIntegrator.java and AdIntegratorHelper.java files in the android/app/../directory.  Edit add your advertising IDs inside the AdIntegrator.java file.


3. Edit the android/app/build.gradle file.  

Add this code just underneath the first line:

repositories {
    jcenter() // includes the MoPub SDK and AVID library
    maven { url "https://s3.amazonaws.com/moat-sdk-builds" }
}

Add this code near the bottom just underneath "// More deps here//":

    compile('com.mopub:mopub-sdk:5.0.0@aar') {
        transitive = true
    }
    implementation 'com.android.support:support-v4:26.1.0'
    implementation 'com.android.support:recyclerview-v7:26.1.0'


4. Edit the android/src/main/AndroidManifest.xml and just before the "<!-- FACEBOOK SDK -->" line add the following code:

<!-- MoPub's consent dialog -->

        <activity android:name="com.mopub.common.privacy.ConsentDialogActivity" android:configChanges="keyboardHidden|orientation|screenSize"/>

        <!-- All ad formats -->

        <activity android:name="com.mopub.common.MoPubBrowser" android:configChanges="keyboardHidden|orientation|screenSize"/>

        <!-- Interstitials -->

        <activity android:name="com.mopub.mobileads.MoPubActivity" android:configChanges="keyboardHidden|orientation|screenSize"/>

        <activity android:name="com.mopub.mobileads.MraidActivity" android:configChanges="keyboardHidden|orientation|screenSize"/>

        <!-- Rewarded Video and Rewarded Playables -->

        <activity android:name="com.mopub.mobileads.RewardedMraidActivity" android:configChanges="keyboardHidden|orientation|screenSize"/>

        <activity android:name="com.mopub.mobileads.MraidVideoPlayerActivity" android:configChanges="keyboardHidden|orientation|screenSize"/>


5. You should now be ready to build to project with custom MoPub support.

Legal Questions on GDPR Compliance?

For GDPR compliance, we cannot advise you on this. I can only direct you to the FAQ from MoPub specifically addressing GDPR in relation to their SDK: https://www.mopub.com/resources/gdpr-faq/

Did this answer your question?