Adapters - mobfox/MobFox-Android-SDK GitHub Wiki

Adapters

Adapters enable you to use the MobFox SDK inside other ad networks SDK's that you are using. This way you can display MobFox ads in addition to ads from other host networks.

Ad Network Banner Interstitial Native Rewarded
MoPub Yes Yes Yes -
AdMob Yes Yes Yes Yes
Smaato Yes Yes Yes -
DFP Yes Yes - -

MoPub

  1. Install the MobFox Android SDK Core.
  2. Install the MoPub Android SDK.
  3. Download the MobFox-Android-MoPub-Adapter.jar and Place it in your application's libs folder (next to your src folder).
  4. Add MobFox-Android-MoPub-Adapter.jar as a dependency in your gradle.build file.
  5. See the docs in MoPub for creating and integrating Banner / Interstitial ads.
  6. Create a MobFox publication.
  7. See the docs in MoPub for implementing Custom Native Networks on the MoPub ads previously created. Note this is a "Custom Native Network" and NOT a "Custom Network".
  8. For banner ads use this CUSTOM EVENT CLASS com.mobfox.sdk.adapters.MoPubBannerAdapter and in CUSTOM EVENT CLASS DATA input: {"invh":"<your-publication-hash>"}. Use your required MobFox's publication hash.
  9. For interstitial (fullscreen) ads use this CUSTOM EVENT CLASS com.mobfox.sdk.adapters.MoPubInterstitialAdapter and in CUSTOM EVENT CLASS DATA input: {"invh":"<your-publication-hash>"}. Use your required MobFox's publication hash. MoPub Set up Custom Native Network
  10. For native ads use this CUSTOM EVENT CLASS com.mobfox.sdk.adapters.MoPubNativeAdAdapter and in CUSTOM EVENT CLASS DATA input: {"invh":"<your-publication-hash>"}. Use your required MobFox's publication hash. make sure you call nativeAd.prepare inside onNativeLoad override. prepare adds a click listener to the View argument and fires the impression pixel necessary to count the impression.
MoPubNative moPubNative = new MoPubNative(this, "<custom-event-adunit>", new MoPubNative.MoPubNativeNetworkListener() {
            @Override
            public void onNativeLoad(NativeAd nativeAd) {
                //make sure you call this method
                nativeAd.prepare(findViewById(R.id.your-layout));
                ...
            }

            @Override
            public void onNativeFail(NativeErrorCode errorCode) {
                ...
            }
        });
  1. Now, when calling your MoPub ads, you should get the respective MobFox ads.
  2. Extra data can be passed to MobFox using the MoPub's localExtras object. "gender", "age" and "location" are supported at the moment. In your MoPub integration code create a new HashMap, and put the extra data in it (e.g. "gender"):
// ...
Map<String, Object> localExtras = new HashMap<>();
localExtras.put("gender", gender);
// ...
  • location:
    • key: "location"
    • format: Location (java class)
  • gender:
    • key: "gender"
    • format: String
    • value: "m|f"
  • age:
    • key: "age"
    • format: Integer

After putting all the data needed in the localExtras HashMap, pass it to the moPubView object:

// ...
moPubView.setLocalExtras(localExtras);
// ...

The data will be appended to your MobFox request.

- GDPR

To comply with the latest GDPR follow the instructions given by MoPub.

AdMob

  1. Install the MobFox Android SDK Core.
  2. Install the AdMob Android SDK.
  3. Place the MobFox-Android-AdMob-Adapter.jar in your application's libs folder (next to your src folder) and add it as a dependency in your gradle.build file.
  4. In your AdMob control panel:

- For Interstitial/Banner Ads

  • Click the Monetize tab.
  • Under All Apps select your app.
  • On the relevant Ad Unit, click the ad sources link.
  • Click the + New ad network button.
  • Select the MobFox network from the available ad networks list.
  • Fill in:
    • Publisher Site ID - your MobFox publication hash.
  • Click CONTINUE

AdMob Set up Custom Native Network

- For Rewarded Video Ads

  • Click the Monetize tab.
  • Under All Apps select your app.
  • On the relevant Rewarded Ad Unit, click the ad sources link.
  • Click the + NEW AD NETWORK button.
  • Click the + CUSTOM EVENT button.
  • Fill in:
    • Class Name - com.mobfox.adapter.MobFoxAdapter
    • Label - a name for the custom event.
    • Parameter - your MobFox publication hash.
  • Click CONTINUE

-GDPR

To comply with the latest GDPR follow the example below:

AdView mAdView = (AdView) findViewById(R.id.adView);  
Bundle bundle = new Bundle();  
bundle.putBoolean("gdpr", true);  
bundle.putString("gdpr_consent", <your-consented-vendor-list>);  
  
  
AdRequest adRequest = new AdRequest.Builder()  
        .addTestDevice("SEE_YOUR_LOGCAT_TO_GET_YOUR_DEVICE_ID")  
        .addNetworkExtrasBundle(MobFoxAdapter.class, bundle)  
        .build();  
  
mAdView.loadAd(adRequest);

Smaato

  1. Install the MobFox Android SDK Core.
  2. Install the Smaato Android SDK.
  3. Place the MobFox-Android-Smaato-Adapter.jar in your application's libs folder (next to your src folder) and add it as a dependency in your gradle.build file.
  4. In your Smaato console:
  • In the networks tab, select custom sdk network and NOT MobFox network (deprecated). For more see Smaato wiki.
  • In edit line item enter the following:
    • for banner ads: Class name: com.mobfox.adapter.MobFoxAdapter, Method Name: loadCustomBanner, Custom Data: {"AD_UNIT_ID": "<your-publication-hash>"} - More custom data can be added, AD_UNIT_ID is the required minimum. See Smaato wiki for more information. Smaato Set up MobFox Custom Banner Network
    • for interstitial ads: Class name: com.mobfox.adapter.MobFoxInterstitialAdapter, Method Name: loadCustomInterstitial, Custom Data: {"AD_UNIT_ID": "<your-publication-hash>"}. Smaato Set up MobFox Custom Interstitial Network

DFP

DFP uses the same adapter as AdMob.

  1. Install the MobFox Android SDK Core.
  2. Install the DFP Android SDK.
  3. Place the MobFox-Android-AdMob-Adapter.jar in your application's libs folder (next to your src folder) and add it as a dependency in your gradle.build file.
  4. In your DFP creative select the MobFox network and put in your MobFox publication hash.

DFP Set up Custom Native Network More DFP custom event documentation can be found here: https://developers.google.com/mobile-ads-sdk/docs/dfp/android/custom-events.