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
- Install the MobFox Android SDK Core.
- Install the MoPub Android SDK.
- Download the MobFox-Android-MoPub-Adapter.jar and Place it in your application's libs folder (next to your src folder).
- Add MobFox-Android-MoPub-Adapter.jar as a dependency in your gradle.build file.
- See the docs in MoPub for creating and integrating Banner / Interstitial ads.
- Create a MobFox publication.
- 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".
- 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. - 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. - 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 callnativeAd.prepare
insideonNativeLoad
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) {
...
}
});
- Now, when calling your MoPub ads, you should get the respective MobFox ads.
- 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
- Install the MobFox Android SDK Core.
- Install the AdMob Android SDK.
- 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. - 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 thead 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
- For Rewarded Video Ads
- Click the
Monetize
tab. - Under
All Apps
select your app. - On the relevant
Rewarded Ad Unit
, click thead 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
- Install the MobFox Android SDK Core.
- Install the Smaato Android SDK.
- 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. - In your Smaato console:
- In the
networks
tab, selectcustom sdk network
and NOTMobFox 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. - for interstitial ads: Class name:
com.mobfox.adapter.MobFoxInterstitialAdapter
, Method Name:loadCustomInterstitial
, Custom Data:{"AD_UNIT_ID": "<your-publication-hash>"}
.
- for banner ads: Class name:
DFP
DFP uses the same adapter as AdMob.
- Install the MobFox Android SDK Core.
- Install the DFP Android SDK.
- 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. - In your DFP creative select the MobFox network and put in your MobFox publication hash.
More DFP custom event documentation can be found here: https://developers.google.com/mobile-ads-sdk/docs/dfp/android/custom-events.