Documentation

In-House Mediation

Integration

šŸš§

Requirements

  • Min Android SDK version - 21 (5.0, Lollipop)
  • Min Gradle version - 7.2
  • Min Android Gradle Plugin version - 7.1.0
repositories {
    // Add BidMachine maven repository
    maven {
        url 'https://artifactory.bidmachine.io/bidmachine'
    }
}
 
dependencies {
    implementation "io.bidmachine:ads:3.1.1"
}

Set Java version to 8:

android {
    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }
}

Device Advertising ID

In mobile apps, there are no cookies. Instead, Ad Manager uses user-resettable identifiers provided by the mobile device's operating system. Typical advertising IDs are AdID (Android) and IDFA (Apple). Mobile advertising IDs allow developers and marketers to track activity for advertising purposes. They're also used to enhance serving and targeting capabilities.

Add Play Services Ads Identifier dependency:

implementation "com.google.android.gms:play-services-ads-identifier:18.0.1"

Network security configuration

Android 9.0 (API 28) blocks cleartext (non-HTTPS) traffic by default, which can prevent ads from being served correctly.

ā—ļø

Failure to comply with this configuration may result in lower display rate, fill rate, rendering errors, and as a result - lower revenue

  1. Add a Network Security Configuration file to your AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest>
    <application android:networkSecurityConfig="@xml/network_security_config" />
</manifest>
  1. In your network_security_config.xml file, add base-config that sets cleartextTrafficPermitted to true:
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <base-config cleartextTrafficPermitted="true">
        <trust-anchors>
            <certificates src="system" />
        </trust-anchors>
    </base-config>
    <debug-overrides>
        <trust-anchors>
            <certificates src="user" />
        </trust-anchors>
    </debug-overrides>
</network-security-config>

Initialization

Initialize SDK, and set your SourceId.

šŸ“˜

To get your SOURCE_ID, visit our website or contact the support.

BidMachine.initialize(@NonNull Context, "<YOUR_SOURCE_ID>");

// or with InitializationCallback
BidMachine.initialize(@NonNull Context, "<YOUR_SOURCE_ID>", @Nullable InitializationCallback);
BidMachine.initialize(Context, "<YOUR_SOURCE_ID>")

// or with InitializationCallback
BidMachine.initialize(Context, "<YOUR_SOURCE_ID>", InitializationCallback?)

Enable logs if required:

BidMachine.setLoggingEnabled(boolean);
BidMachine.setLoggingEnabled(Boolean)

Enable test mode:

BidMachine.setTestMode(boolean);
BidMachine.setTestMode(Boolean)

Set your endpoint before initialization if required:

BidMachine.setEndpoint(@NonNull String);
BidMachine.setEndpoint(String)

SDK can automatically track user device location to serve better ads. To make it work for Android 6.0, you should request android.permission.ACCESS_COARSE_LOCATION and android.permission.ACCESS_FINE_LOCATION:

ActivityCompat.requestPermissions(@NonNull Activity, new String[]{
        Manifest.permission.ACCESS_COARSE_LOCATION,
        Manifest.permission.ACCESS_FINE_LOCATION
}, REQ_CODE);
ActivityCompat.requestPermissions(Activity, arrayOf<String>(
    Manifest.permission.ACCESS_COARSE_LOCATION,
    Manifest.permission.ACCESS_FINE_LOCATION
), REQ_CODE)

Request parameters

User Restriction Parameters

ParamTypeDescription
GDPR Consent StringStringGDPR consent string (if applicable), indicating the compliance with the IAB standard Consent String Format of the Transparency and ConsentFramework technical specifications.
Subject to GDPRBooleanFlag indicating if GDPR regulations apply The General Data Protection Regulation (GDPR) is a regulation of the European Union.
CoppaBooleanFlag indicating if COPPA regulations apply. The Children's Online Privacy Protection Act (COPPA) was established by the U.S. Federal Trade Commission.
US Privacy StringStringCCPA string if applicable, compliant with the IAB standard CCPA String Format
GPP StringStringGPP string if applicable, compliant with the IAB standard GPP String Format
GPP IdsList<Integer>GPP ids

Code Example:

// Set COPPA
BidMachine.setCoppa(@Nullable Boolean);

// Set subject to GDPR
BidMachine.setSubjectToGDPR(@Nullable Boolean);

// Set consent config
BidMachine.setConsentConfig(boolean, @Nullable String);

// Set CCPA
BidMachine.setUSPrivacyString(@Nullable String);

// Set GPP
BidMachine.setGPP(@Nullable String, @Nullable List<Integer>);
// Set COPPA
BidMachine.setCoppa(Boolean?)

// Set subject to GDPR
BidMachine.setSubjectToGDPR(Boolean?)

// Set consent config
BidMachine.setConsentConfig(Boolean, String?)

// Set CCPA
BidMachine.setUSPrivacyString(String?)

// Set GPP
BidMachine.setGPP(String?, List<Int>?)

COPPA

To help ensure compliance with COPPA you must indicate whether a user falls within an age-restricted category. To pass COPPA to BidMachine, use:

BidMachine.setCoppa(@Nullable Boolean);
BidMachine.setCoppa(Boolean?)

GDPR

The Publisher needs to send a boolean flag indicating if GDPR applies to the current user.
If so, the Publisher also needs to collect user consent prior to requesting any ads from the Exchange server. More information about collecting consent is here.

SDK has public methods to transfer GDPR data. Also, SDK automatically retrieves GDPR from SharedPreference. If you would like to pass GDPR according to IAB standards, please add it in SharedPreference.

When using several methods of data transfer at once, priority is given to the SDK public method, then TCF 2.0, then TCF 1.0.

Some adapters don't have a public API for the GDPR data to be passed to them. Such adapters will read GDPR from the SharedPreference.

GDPR Applies

SDK public method:

BidMachine.setSubjectToGDPR(@Nullable Boolean);
BidMachine.setSubjectToGDPR(Boolean?)

Example TFC 2.0:

PreferenceManager.getDefaultSharedPreferences(Context)
        .edit()
        .putInt("IABTCF_gdprApplies", <GDPR APPLIES>)
        .apply();
PreferenceManager.getDefaultSharedPreferences(Context)
        .edit {
            putInt("IABTCF_gdprApplies", <GDPR APPLIES>)
        }

Example TFC 1.0:

PreferenceManager.getDefaultSharedPreferences(Context)
        .edit()
        .putString("IABConsent_SubjectToGDPR", "<GDPR APPLIES>")
        .apply();
PreferenceManager.getDefaultSharedPreferences(Context)
        .edit {
            putString("IABConsent_SubjectToGDPR", "<GDPR APPLIES>")
        }

GDPR Consent String

SDK public method

BidMachine.setConsentConfig(boolean, @Nullable String);
BidMachine.setConsentConfig(Boolean, String?)

Example TCF 2.0:

PreferenceManager.getDefaultSharedPreferences(Context)
        .edit()
        .putString("IABTCF_TCString", "<GDPR CONSENT STRING>")
        .apply();
PreferenceManager.getDefaultSharedPreferences(Context)
        .edit {
            putString("IABTCF_TCString", "<GDPR CONSENT STRING>")
        }

Example TCF 1.0:

PreferenceManager.getDefaultSharedPreferences(Context)
        .edit()
        .putString("IABConsent_ConsentString", "<GDPR CONSENT STRING>")
        .apply();
PreferenceManager.getDefaultSharedPreferences(Context)
        .edit {
            putString("IABConsent_ConsentString", "<GDPR CONSENT STRING>")
        }

CCPA

To pass CCPA U.S. Privacy String to BidMachine, use:

BidMachine.setUSPrivacyString(@Nullable String);
BidMachine.setUSPrivacyString(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.

PreferenceManager.getDefaultSharedPreferences(Context)
        .edit()
        .putString("IABUSPrivacy_String", "<IAB CCPA U.S. PRIVACY STRING>")
        .apply();
PreferenceManager.getDefaultSharedPreferences(Context)
        .edit {
            putString("IABUSPrivacy_String", "<IAB CCPA U.S. PRIVACY STRING>")
        }

Some adapters don't have a public API for the CCPA U.S. Privacy String to be passed to them. Such adapters will read this from the SharedPreference.

GPP

To pass GPP to BidMachine, use:

BidMachine.setGPP(@Nullable String, @Nullable List<Integer>);
BidMachine.setGPP(String?, List<Int>?)

Also, SDK automatically retrieves GPP from SharedPreference. If you would like to pass GPP according to IAB standards, please add it in SharedPreference. More information here and here

PreferenceManager.getDefaultSharedPreferences(Context)
        .edit()
        .putString("IABGPP_HDR_GppString", "<IAB GPP STRING>")
        .putString("IABGPP_GppSID", "<IAB GPP IDs STRING>")
        .apply();
PreferenceManager.getDefaultSharedPreferences(Context)
        .edit {
            putString("IABGPP_HDR_GppString", "<IAB GPP STRING>")
            putString("IABGPP_GppSID", "<IAB GPP IDs STRING>")
        }

Publisher

To pass information about the publisher, use the public method:

BidMachine.setPublisher(@Nullable Publisher);
BidMachine.setPublisher(Publisher?)
ParamTypeDescription
IdStringPublisher ID
NameStringPublisher name
DomainStringPublisher domain
CategoryStringPublisher content category

Code Example:

Publisher publisher = new Publisher.Builder()
        .setId(@Nullable String)
        .setName(@Nullable String)
        .setDomain(@Nullable String)
        .addCategory(@Nullable String)
        .addCategories(@Nullable List<String>)
        .build();

// Sets publisher information
BidMachine.setPublisher(publisher);
val publisher = Publisher.Builder()
        .setId(String?)
        .setName(String?)
        .setDomain(String?)
        .addCategory(String?)
        .addCategories(List<String>?)
        .build()

// Sets publisher information
BidMachine.setPublisher(publisher)

Targeting Parameters

ParamTypeDescription
User IdStringVendor-specific ID for the user.
GenderEnumGender, one of the following:
Female, Male, Omitted.
Year of BirthIntegerYear of birth as a 4-digit integer (e.g. - 1990).
KeywordsString[]List of keywords, interests, or intents (separated by comma if you use .xml).
Device LocationLocationLocation of the device. It may not be the location sent to the server, as it is compared to the current device location at the time, when it was received.
CountryStringCountry of the user's domicile (i.e. not necessarily their current location).
CityStringCity of the user's domicile (i.e. not necessarily their current location).
ZipStringZip of the user's domicile (i.e. not necessarily their current location).
Store UrlStringApp store URL for an installed app; for IQG 2.1 compliance.
Store CategoryStringSets App store category definitions (e.g. - "games").
Store Sub CategoryString[]Sets App Store Subcategory definitions. The array is always capped at 3 strings.
Framework NameStringSets app framework definitions.
PaidBooleanDetermines, if the app version is free or paid version of the app.
External User IdsList<ExternalUserId>Set external user ID list.
Blocked Advertiser IAB CategoryString[]Block list of content categories by IDs.
Blocked Advertiser DomainString[]Block list of advertisers by their domains (e.g., ā€œexample.comā€).
Blocked ApplicationString[]Block list of apps where ads are disallowed. These should be bundle or package names (e.g., ā€œcom.foo.mygameā€) and should NOT be app store IDs (e.g., not iTunes store IDs).

Code Example:

TargetingParams targetingParams = new TargetingParams()
        .setUserId(@Nullable String)
        .setGender(@Nullable Gender)
        .setBirthdayYear(@Nullable Integer)
        .setKeywords(@Nullable String[])
        .setDeviceLocation(@Nullable Location)
        .setCountry(@Nullable String)
        .setCity(@Nullable String)
        .setZip(@Nullable String)
        .setStoreUrl(@Nullable String)
        .setStoreCategory(@Nullable String)
        .setStoreSubCategories(@Nullable String[])
        .setFramework(@Nullable String)
        .setPaid(@Nullable Boolean)
        .setExternalUserIds(@Nullable List<ExternalUserId>)
        .addBlockedAdvertiserIABCategory(@NonNull String)
        .addBlockedAdvertiserDomain(@NonNull String)
        .addBlockedApplication(@NonNull String);
val targetingParams = TargetingParams()
        .setUserId(String?)
        .setGender(Gender?)
        .setBirthdayYear(Int?)
        .setKeywords((vararg String)?)
        .setDeviceLocation(Location?)
        .setCountry(String?)
        .setCity(String?)
        .setZip(String?)
        .setStoreUrl(String?)
        .setStoreCategory(String?)
        .setStoreSubCategories((vararg String)?)
        .setFramework(String?
        .setPaid(Boolean?)
        .setExternalUserIds(List<ExternalUserId>?)
        .addBlockedAdvertiserIABCategory(String)
        .addBlockedAdvertiserDomain(String)
        .addBlockedApplication(String)

TargetingParams can be passed with 2 ways:

  • Through global parameters:
BidMachine.setTargetingParams(targetingParams);
BidMachine.setTargetingParams(targetingParams)
  • Through ad request builder:
adRequestBuilder.setTargetingParams(targetingParams);
adRequestBuilder.setTargetingParams(targetingParams)

You can combine global parameters with regular. If you set Global TargetingParams using UserId, and then make a request using TargetingParams with Gender set, both requests will be merged and the resulting TargetingParams will include both UserId and Gender.

šŸ“˜

Priority is given to the AdRequest parameters.

Price Floor Parameters

ParameterTypeDescription
IdStringUnique floor identifier.
PricedoubleFloor price

If you use the method with only Price provided PriceFloorParams.addPriceFloor(Double), the Id will be generated using UUID.randomUUID().

Code Example:

PriceFloorParams priceFloorParams = new PriceFloorParams()
        // Set Bid Price, in this case id will be generated
        .addPriceFloor(double)
        // Set Bid Id and Price
        .addPriceFloor(@NonNull String, double);
val priceFloorParams = PriceFloorParams()
        // Set Bid Price, in this case id will be generated
        .addPriceFloor(Double)
        // Set Bid Id and Price
        .addPriceFloor(String, Double)

To set up price floor parameters for ad request use setPriceFloorParams method from AdRequest builder according to ads type.

adRequestBuilder.setPriceFloorParams(priceFloorParams);
adRequestBuilder.setPriceFloorParams(priceFloorParams)

Session Ad Parameters

ParamTypeDescription
Session DurationIntegerThe total duration of time a user has spent so far in a specific app session expressed in seconds.
Impression CountIntegerThe count of impressions for a specific placement type in a given app session.
Click RateFloatThe percentage of clicks/impressions per user per placement type over a given number of impressions.
Is User Clicked On Last AdBooleanA boolean value indicating if the user clicked on the last impression in a given session per placement type.
Completion RateFloatThe percentage of successful completions/impressions per user per placement type for a given number of impressions.
This only applies to Rewarded and Video placement types.

Code Example:

SessionAdParams sessionAdParams = new SessionAdParams()
        .setSessionDuration(@Nullable Integer)
        .setImpressionCount(@Nullable Integer)
        .setClickRate(@Nullable Float)
        .setIsUserClickedOnLastAd(@Nullable Boolean)
        .setCompletionRate(@Nullable Float);
val sessionAdParams = SessionAdParams()
        .setSessionDuration(Integer?)
        .setImpressionCount(Integer?)
        .setClickRate(Float?)
        .setIsUserClickedOnLastAd(Boolean?)
        .setCompletionRate(Float?)

To set up session ad parameters for ad request use setSessionAdParams method from AdRequest builder according to ads type.

adRequestBuilder.setSessionAdParams(sessionAdParams);
adRequestBuilder.setSessionAdParams(sessionAdParams)

Custom Parameters

Code Example:

CustomParams customParams = new CustomParams()
        .addParam(@NonNull String, @NonNull String)
        .addParams(@NonNull Map<String, String>);
val customParams = CustomParams()
        .addParam(String, String)
        .addParams(Map<String, String>)

To set up custom parameters for ad request use setCustomParams method from AdRequest builder according to ads type.

adRequestBuilder.setCustomParams(customParams);
adRequestBuilder.setCustomParams(customParams)

Placement Id

To set up placement id for current impression use setPlacementId method from AdRequest builder according to ads type.

adRequestBuilder.setPlacementId(@Nullable String);
adRequestBuilder.setPlacementId(String?)

Bid Payload

To set up bid payload for ad request use setBidPayload method from AdRequest builder according to ads type.

adRequestBuilder.setBidPayload(@Nullable String);
adRequestBuilder.setBidPayload(String?)

Example

Auction result

ParameterTypeDescriptionSample
IdStringWinner bid ID provided in the request."cc5bd14b-aaef-4037-b4f8-879913366e3c"
Demand SourceStringWinner advertising source name."BidMachine Test"
PricedoubleWinner price expressed as CPM.0.023
DealStringId of Price Floor."d6f61bf9-11a8-4172-a77d-4b1ff85a727f"
Creative IdStringWinner creative id."123.13579"
CIDStringWinner Campaign ID or other similar grouping of brand-related ads."123.13587"
Ad DomainString[]Winner advertiser domain (top two levels only e.g., "ford.com").["sample1.com", "sample2.com"]
Network KeyStringWinner network key. This network will be loaded."mraid"
Network ParamsMap<String, String>Client parameters of winner networks.
Creative FormatEnumCreativeFormat, one of the following:
Banner, Video, Native.
CreativeFormat.Video
Custom ParamsMap<String, String>Map that contains additional information about the response.

You can get AuctionResult in two ways:

  • Through AdRequestListener. Use AuctionResult from onRequestSuccess callback
adRequestBuilder.setListener(new <AdRequestObject>.AdRequestListener() {
    @Override
    public void onRequestSuccess(@NonNull <AdRequestObject> adRequest,
                                 @NonNull AuctionResult auctionResult) {
        // Use AuctionResult from onRequestSuccess callback
    }
});
adRequestBuilder.setListener(object : <AdRequestObject>.AdRequestListener {
    override fun onRequestSuccess(adRequest: <AdRequestObject>,
                                  auctionResult: AuctionResult) {
        // Use AuctionResult from onRequestSuccess callback
    }
});
  • Through getter. Each AdRequest has an option to retrieve auction result information after it has been loaded.
adRequest.getAuctionResult();
adRequest.auctionResult;

Win/Loss notifications

Call notifyMediationWin/notifyMediationLoss on the AdRequest instance when BidMachine wins/loses the mediation among networks.

  • Win notification:
adRequest.notifyMediationWin();
adRequest.notifyMediationWin()
  • Loss notification:
adRequest.notifyMediationLoss("<WINNER_NETWORK_NAME>", <WINNER_NETWORK_PRICE>);
// or
adRequest.notifyMediationLoss();
adRequest.notifyMediationLoss("<WINNER_NETWORK_NAME>", <WINNER_NETWORK_PRICE>)
// or
adRequest.notifyMediationLoss()

Bid Token

With S2S integration, you will need a BidToken that you need to transfer in the request. To get a BidToken, you can use one of 2 methods:

// Must be run on background thread
String bidToken = BidMachine.getBidToken(@NonNull Context, @Nullable AdsFormat);
// Must be run on background thread
val bidToken = BidMachine.getBidToken(Context, AdsFormat?)

or

BidMachine.getBidToken(@NonNull Context, @Nullable AdsFormat, new BidTokenCallback() {
    @Override
    public void onCollected(@NonNull String bidToken) {
        // The BidToken will be returned on a background thread
    }
});
BidMachine.getBidToken(Context, AdsFormat?) { bidToken ->
    // The BidToken will be returned on a background thread
}

Custom init server configuration parameters

You can get the configuration from the BM server using a pre-agreed key

Object param = BidMachine.getExtrasParam(@NonNull Context, @NonNull String);
val param: Any? = BidMachine.getExtrasParam(Context, String)

3rd party SDK integration (Header-Bidding)

You can find all integration code examples written in Java and KotlinĀ here

šŸš§

All 3rd party networks should be configured and registered before SDK initialization


AdColony

šŸ“˜

Supported ad types

  • Interstitial
  • Rewarded

Add this to Module-levelĀ build.gradleĀ beforeĀ dependencies:

repositories {
    google()
    mavenCentral() 
}

Add the following dependency to you build.gradle:

dependencies {
    implementation "io.bidmachine:ads.networks.adcolony:3.1.1.11"
}

Configure network:

BidMachine.registerNetworks(
        new AdColonyConfig("YOUR_APP_ID")
                .withMediationConfig(AdsFormat.InterstitialVideo, "YOUR_ZONE_ID")
                .withMediationConfig(AdsFormat.RewardedVideo, "YOUR_ZONE_ID"));
BidMachine.registerNetworks(
    AdColonyConfig("YOUR_APP_ID")
        .withMediationConfig(AdsFormat.InterstitialVideo, "YOUR_ZONE_ID")
        .withMediationConfig(AdsFormat.RewardedVideo, "YOUR_ZONE_ID"))

šŸ“˜

By default, we provide google as storeId parameter to AdColony network


Amazon

šŸ“˜

Supported ad types

  • Banner
  • Interstitial
  • Rewarded

Add this to Module-levelĀ build.gradleĀ beforeĀ dependencies:

repositories {
    mavenCentral()
}

Add next dependency to youĀ build.gradle:

dependencies {
    implementation "io.bidmachine:ads.networks.amazon:3.1.1.15"
}

ConfigureĀ network:

BidMachine.registerNetworks(
        new AmazonConfig("YOUR_APP_KEY")
               .withMediationConfig(AdsFormat.Banner_320x50, "YOUR_SLOT_UUID")
               .withMediationConfig(AdsFormat.Banner_300x250, "YOUR_SLOT_UUID")
               .withMediationConfig(AdsFormat.Banner_728x90, "YOUR_SLOT_UUID")
               .withMediationConfig(AdsFormat.InterstitialStatic, "YOUR_SLOT_UUID")
               .withMediationConfig(AdsFormat.InterstitialVideo, "YOUR_SLOT_UUID"));
BidMachine.registerNetworks(
    AmazonConfig("YOUR_APP_KEY")
        .withMediationConfig(AdsFormat.Banner_320x50, "YOUR_SLOT_UUID")
        .withMediationConfig(AdsFormat.Banner_300x250, "YOUR_SLOT_UUID")
        .withMediationConfig(AdsFormat.Banner_728x90, "YOUR_SLOT_UUID")
        .withMediationConfig(AdsFormat.InterstitialStatic, "YOUR_SLOT_UUID")
        .withMediationConfig(AdsFormat.InterstitialVideo, "YOUR_SLOT_UUID"))

šŸš§

IAB TCFv2

Amazon support only IAB TCFv2.
IAB TCFv1 is not supported, see


Criteo

šŸ“˜

Supported ad types

  • Banner
  • Interstitial

Add this to Module-levelĀ build.gradleĀ beforeĀ dependencies:

repositories {
    google()
    mavenCentral()
}

Add the following dependency to you build.gradle:

dependencies {
    implementation "io.bidmachine:ads.networks.criteo:3.1.1.13"
}

Configure network:

BidMachine.registerNetworks(
        new CriteoConfig("YOUR_PUBLISHER_ID")
        		.withMediationConfig(AdsFormat.Banner_320x50, "YOUR_AD_UNIT_ID")
                .withMediationConfig(AdsFormat.Banner_300x250, "YOUR_AD_UNIT_ID")
                .withMediationConfig(AdsFormat.Banner_728x90, "YOUR_AD_UNIT_ID")
                .withMediationConfig(AdsFormat.InterstitialStatic, "YOUR_AD_UNIT_ID"));
BidMachine.registerNetworks(
    CriteoConfig("YOUR_PUBLISHER_ID")
        .withMediationConfig(AdsFormat.Banner_320x50, "YOUR_AD_UNIT_ID")
        .withMediationConfig(AdsFormat.Banner_300x250, "YOUR_AD_UNIT_ID")
        .withMediationConfig(AdsFormat.Banner_728x90, "YOUR_AD_UNIT_ID")
        .withMediationConfig(AdsFormat.InterstitialStatic, "YOUR_AD_UNIT_ID"))

Google AdManager

šŸ“˜

Supported ad types

  • Banner
  • Interstitial
  • Rewarded

Add this to Project-level build.gradle before dependencies:

buildscript {
    repositories {
        google()
        mavenCentral()
    }
}

Add this to Module-levelĀ build.gradleĀ beforeĀ dependencies:

repositories {
    google()
    mavenCentral()
}

Add the following dependency to you build.gradle:

dependencies {
    implementation "com.google.android.gms:play-services-ads:23.0.0"
}

šŸ“˜

Supported versions

You can use any version from 21.0.0 to 23.0.0 for com.google.android.gms:play-services-ads dependency.

Add APPLICATION_ID to AndroidManifest.xml:

<manifest>
    <application>
        <!-- Sample Ad Manager app ID: ca-app-pub-3940256099942544~3347511713 -->
        <meta-data
            android:name="com.google.android.gms.ads.APPLICATION_ID"
            android:value="ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy"/>
    </application>
</manifest>

šŸ“˜

If ANRs are observed when loading ad, then you can specify a special flag in AndroidManifest.xml that will move the loading of ad to the background thread.

<manifest>
    <application>
        <meta-data
            android:name="com.google.android.gms.ads.flag.OPTIMIZE_AD_LOADING"
            android:value="true"/>
    </application>
</manifest>

Optimize initialization and ad loading


MetaAudience

šŸ“˜

Supported ad types

  • Banner
  • Interstitial
  • Rewarded
  • Native (Experimental)

Add this to Module-levelĀ build.gradleĀ beforeĀ dependencies:

repositories {
    mavenCentral() 
}

Add the following dependency to you build.gradle:

dependencies {
    implementation "io.bidmachine:ads.networks.meta_audience:3.1.1.16"
}

Update your network_security_config.xml file, add domain-configĀ that setsĀ cleartextTrafficPermittedĀ toĀ true:

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <domain-config cleartextTrafficPermitted="true">
        <domain includeSubdomains="true">127.0.0.1</domain>
    </domain-config>
</network-security-config>

Configure network:

BidMachine.registerNetworks(
        new MetaAudienceConfig("YOUR_APP_ID")
                .withMediationConfig(AdsFormat.Banner, "YOUR_PLACEMENT_ID")
                .withMediationConfig(AdsFormat.Banner_300x250, "YOUR_PLACEMENT_ID")
                .withMediationConfig(AdsFormat.InterstitialStatic, "YOUR_PLACEMENT_ID")
                .withMediationConfig(AdsFormat.RewardedVideo, "YOUR_PLACEMENT_ID")
                .withMediationConfig(AdsFormat.Native, "YOUR_PLACEMENT_ID"));
BidMachine.registerNetworks(
    MetaAudienceConfig("YOUR_APP_ID")
        .withMediationConfig(AdsFormat.Banner, "YOUR_PLACEMENT_ID")
        .withMediationConfig(AdsFormat.Banner_300x250, "YOUR_PLACEMENT_ID")
        .withMediationConfig(AdsFormat.InterstitialStatic, "YOUR_PLACEMENT_ID")
        .withMediationConfig(AdsFormat.RewardedVideo, "YOUR_PLACEMENT_ID")
        .withMediationConfig(AdsFormat.Native, "YOUR_PLACEMENT_ID"))

šŸš§

Native (Experimental)

MetaAudience native have two type:

  • Native Banner Ads
  • Native Ads

Native ads may not work correctly if MetaAudience placements were submitted that did not match the selected MediaAssetType. For example, if you want use MediaAssetType.Icon, you need submit placements of Native Banner Ads type, otherwise you need submit placements of Native Ads type.


Mintegral

šŸ“˜

Supported ad types

  • Banner
  • Interstitial
  • Rewarded

Add the following dependency to you build.gradle:

dependencies {
    implementation "io.bidmachine:ads.networks.mintegral:3.1.1.11"
}

Configure network:

BidMachine.registerNetworks(
        new MintegralConfig("YOUR_APP_ID", "YOUR_APP_KEY")
                .withMediationConfig(AdsFormat.Banner, "YOUR_AD_UNIT_ID")
                .withMediationConfig(AdsFormat.Interstitial, "YOUR_AD_UNIT_ID")
                .withMediationConfig(AdsFormat.Rewarded, "YOUR_AD_UNIT_ID"));
BidMachine.registerNetworks(
    MintegralConfig("YOUR_APP_ID", "YOUR_APP_KEY")
        .withMediationConfig(AdsFormat.Banner, "YOUR_AD_UNIT_ID")
        .withMediationConfig(AdsFormat.Interstitial, "YOUR_AD_UNIT_ID")
        .withMediationConfig(AdsFormat.Rewarded, "YOUR_AD_UNIT_ID"))

myTarget

šŸ“˜

Supported ad types

  • Banner
  • Interstitial
  • Rewarded

Add the following dependency to you build.gradle:

dependencies {
    implementation "io.bidmachine:ads.networks.my_target:3.1.1.17"
}

Configure network:

BidMachine.registerNetworks(
        new MyTargetConfig()
               .withMediationConfig(AdsFormat.Banner, "YOUR_SLOT_ID")
               .withMediationConfig(AdsFormat.Banner_320x50, "YOUR_SLOT_ID")
               .withMediationConfig(AdsFormat.Banner_300x250, "YOUR_SLOT_ID")
               .withMediationConfig(AdsFormat.Banner_728x90, "YOUR_SLOT_ID")
               .withMediationConfig(AdsFormat.InterstitialStatic, "YOUR_SLOT_ID")
               .withMediationConfig(AdsFormat.RewardedVideo, "YOUR_SLOT_ID"));
BidMachine.registerNetworks(
    MyTargetConfig()
        .withMediationConfig(AdsFormat.Banner, "YOUR_SLOT_ID")
        .withMediationConfig(AdsFormat.Banner_320x50, "YOUR_SLOT_ID")
        .withMediationConfig(AdsFormat.Banner_300x250, "YOUR_SLOT_ID")
        .withMediationConfig(AdsFormat.Banner_728x90, "YOUR_SLOT_ID")
        .withMediationConfig(AdsFormat.InterstitialStatic, "YOUR_SLOT_ID")
        .withMediationConfig(AdsFormat.RewardedVideo, "YOUR_SLOT_ID"))

Pangle

šŸ“˜

Supported ad types

  • Banner
  • Interstitial
  • Rewarded

Add the following dependency to you build.gradle:

dependencies {
    implementation "io.bidmachine:ads.networks.pangle:3.1.1.9"
}

Configure network:

BidMachine.registerNetworks(
        new PangleConfig("YOUR_APP_ID")
                .withMediationConfig(AdsFormat.Banner, "YOUR_SLOT_ID")
                .withMediationConfig(AdsFormat.Interstitial, "YOUR_SLOT_ID")
                .withMediationConfig(AdsFormat.Rewarded, "YOUR_SLOT_ID"));
BidMachine.registerNetworks(
    PangleConfig("YOUR_APP_ID")
        .withMediationConfig(AdsFormat.Banner, "YOUR_SLOT_ID")
        .withMediationConfig(AdsFormat.Interstitial, "YOUR_SLOT_ID")
        .withMediationConfig(AdsFormat.Rewarded, "YOUR_SLOT_ID"))

Vungle

šŸ“˜

Supported ad types

  • Banner
  • Interstitial
  • Rewarded

Add this to Module-levelĀ build.gradleĀ beforeĀ dependencies:

repositories {
    google()
    mavenCentral()
}

Add the following dependency to you build.gradle:

dependencies {
    implementation "io.bidmachine:ads.networks.vungle:3.1.1.7"
}

Configure network:

BidMachine.registerNetworks(
        new VungleConfig("YOUR_APP_ID", "YOUR_PUBLISHER_ID")
                .withMediationConfig(AdsFormat.InterstitialVideo, "YOUR_PLACEMENT_ID")
                .withMediationConfig(AdsFormat.RewardedVideo, "YOUR_PLACEMENT_ID"));
BidMachine.registerNetworks(
    VungleConfig("YOUR_APP_ID", "YOUR_PUBLISHER_ID")
        .withMediationConfig(AdsFormat.InterstitialVideo, "YOUR_PLACEMENT_ID")
        .withMediationConfig(AdsFormat.RewardedVideo, "YOUR_PLACEMENT_ID"));