AdMob Waterfall
Integration
Android
Min Android SDK version - 21 (6.0, Marshmallow)
repositories {
// Add BidMachine maven repository
maven {
name "BidMachine Ads maven repository"
url "https://artifactory.bidmachine.io/bidmachine"
}
}
In your build.gradle file add the following dependency which includes the BidMachine adapter for use within AdMob platform:
dependencies {
// Add BidMachine SDK dependency
implementation "io.bidmachine:ads:3.2.1"
// Add BidMachine SDK AdMob Adapter dependency
implementation "io.bidmachine:ads.adapters.admob:3.2.1.43"
// Add AdMob SDK dependency
implementation "com.google.android.gms:play-services-ads:24.1.0"
}
iOS
In your Podfile file add the following dependency which includes the BidMachine adapter for use within AdMob platform:
target 'Target' do
project 'Project.xcodeproj'
pod 'BidMachineAdMobAdapter', '~> 3.3.0.0'
end
Initialization
Android
Waterfall integration does not require BidMachineSdk
initialization code, as it is triggered automatically as part of the MobileAds
initialization.
- Java
- Kotlin
MobileAds.initialize(context, new OnInitializationCompleteListener() {
@Override
public void onInitializationComplete (InitializationStatus initializationStatus){
// Request ads
}
});
MobileAds.initialize(context) {
// Optionally, enable test mode and logging
BidMachine.setTestMode(true)
BidMachine.setLoggingEnabled(true)
}
iOS
The BidMachineAdMobAdapter strarting 3.1.1.2 version offers robust support for waterfall integration. This integration type require to configure mediation groups in AdMob account by adding BidMachine Custom Events and Mappings.
Waterfall integration does not require BidMachineSdk initialization code, as it is triggered automatically as part of the MobileAds initialization.
However, if you need to configure additional BidMachineSdk settings, refer to the Logging and Test Mode below.
Logging and Test Mode
- Java
- Kotlin
- Swift
- Objective-C
BidMachine.setTestMode(true);
BidMachine.setLoggingEnabled(true);
BidMachine.setTestMode(true);
BidMachine.setLoggingEnabled(true);
All parameters for BidMachine SDK must be set before starting AdMob SDK.
BidMachineSdk.shared.populate { builder in
builder
.withTestMode(true)
.withLoggingMode(true)
.withBidLoggingMode(true)
.withEventLoggingMode(true)
}
MobileAds.shared.start(completionHandler: nil)
All parameters for BidMachine SDK must be set before starting AdMob SDK.
[BidMachineSdk.shared populate:^(id<BidMachineInfoBuilderProtocol> builder) {
[builder withTestMode:YES];
[builder withLoggingMode:YES];
[builder withBidLoggingMode:YES];
[builder withEventLoggingMode:YES];
}];
Don't forget to remove setTestMode()
before releasing to production!
Additional Configuration
If you need to configure additional BidMachineSdk
settings, refer to the documentation for Android SDK or iOS SDK.
GDPR Applies
- Java
- Kotlin
BidMachine.setSubjectToGDPR(<GDPR APPLIES>);
BidMachine.setSubjectToGDPR(<GDPR APPLIES>)
TCF 2.0
- Java
- Kotlin
PreferenceManager.getDefaultSharedPreferences(this)
.edit()
.putInt("IABTCF_gdprApplies", <GDPR APPLIES>)
.apply();
PreferenceManager.getDefaultSharedPreferences(this)
.edit()
.putInt("IABTCF_gdprApplies", <GDPR APPLIES>)
.apply()
TCF 1.0
- Java
- Kotlin
PreferenceManager.getDefaultSharedPreferences(this)
.edit()
.putString("IABConsent_SubjectToGDPR", "<GDPR APPLIES>")
.apply();
PreferenceManager.getDefaultSharedPreferences(this)
.edit()
.putString("IABConsent_SubjectToGDPR", "<GDPR APPLIES>")
.apply()
GDPR Consent String
- Java
- Kotlin
BidMachine.setConsentConfig(..., "<GDPR CONSENT STRING>");
BidMachine.setConsentConfig(..., "<GDPR CONSENT STRING>")
TCF 2.0
- Java
- Kotlin
PreferenceManager.getDefaultSharedPreferences(this)
.edit()
.putString("IABTCF_TCString", "<GDPR CONSENT STRING>")
.apply();
PreferenceManager.getDefaultSharedPreferences(this)
.edit()
.putString("IABTCF_TCString", "<GDPR CONSENT STRING>")
.apply()
TCF 1.0
- Java
- Kotlin
PreferenceManager.getDefaultSharedPreferences(this)
.edit()
.putString("IABConsent_ConsentString", "<GDPR CONSENT STRING>")
.apply();
PreferenceManager.getDefaultSharedPreferences(this)
.edit()
.putString("IABConsent_ConsentString", "<GDPR CONSENT STRING>")
.apply()
CCPA
To pass CCPA U.S. Privacy String to BidMachine use:
- Java
- Kotlin
BidMachine.setUSPrivacyString("<IAB CCPA U.S. PRIVACY STRING>");
BidMachine.setUSPrivacyString("<IAB CCPA U.S. PRIVACY STRING>")
Also, SDK automatically retrieves CCPA U.S. Privacy String from SharedPreference
. If you would like to pass CCPA U.S. Privacy String according to IAB standards, please add it in SharedPreference
. More information here and here.
- Java
- Kotlin
PreferenceManager.getDefaultSharedPreferences(this)
.edit()
.putString("IABUSPrivacy_String", "<IAB CCPA U.S. PRIVACY STRING>")
.apply();
PreferenceManager.getDefaultSharedPreferences(this)
.edit()
.putString("IABUSPrivacy_String", "<IAB CCPA U.S. PRIVACY STRING>")
.apply()
Some adapters don't have a public API for the CCPA U.S. Privacy String to be passed to them. Such adapters read this from the SharedPreference
.
Ad Format
Next, choose the ad format that best fits your app’s user experience.