Facebook Mediation Guide - uc-union/union-ads-sdk-demo GitHub Wiki

Introduction

For more details please go to Facebook website

Integration Guide

Android Studio / Gradle (Highly recommended)

Add the following repositories info to project section of build.gradle file, more details in build.gradle.

repositories {
    mavenCentral()
}

Add dependencies dependency (usually defined in app/build.gradle), more details in app/build.gradle

dependencies {
    'com.facebook.android:audience-network-sdk:4.+'
}

Add the following contents to AndroidManifest.xml, more details in AndroidManifest.xml.

<application android:label="@string/app_name">
    ...
    <activity android:name="com.facebook.ads.InterstitialAdActivity"
        android:configChanges="keyboardHidden|orientation|screenSize" />
</application>

Eclipse

Note: If you use Android Studio,you can skip this section.

Download Facebook Audience Network SDK

NOTE: Facebook Audience Network SDK is in aar format.

Download the corresponding SDK from official Facebook site Download Page

Integrate SDK into your eclipse project

Decompress AudienceNetwork.aar locally, you will get the following directory structure.

AudienceNetwork.aar
    |--(Directories)
    |--AndroidManifest.xml
    |--proguard.txt
    |--classes.jar

Follow the steps below:

  1. Rename classes.jar into facebookads.jar and put it in the libs directory

  2. Merge the content of proguard.txt into proguard.pro of the developer's project.

  3. Add the following content to AndroidManifest.xml

    <!-- Include required permissions -->
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    
    <application android:label="@string/app_name">
        ...
        <activity android:name="com.facebook.ads.InterstitialAdActivity"
            android:configChanges="keyboardHidden|orientation|screenSize" />
    </application>

Test

Showing Test Ads

When running on the simulator, test ads will be shown by default. To enable test ads on a device, add the HASH_ID before loading an ad:

AdRequest request =
    AdRequest.newBuilder().testDeviceId("YOUR_HASH_ID").put("YOUR_PUB").build();

YOUR_HASH_ID is printed to the logcat when you first make a request to load an ad on a device. Example:

facebook-test-device-id

Snapshot For Test Ads

Once you load an ad with test device id, you should see something like this:

  • Banner

    facebook-test-banner-example

  • Interstitial

    facebook-test-interstitial-example

Next Steps

⚠️ **GitHub.com Fallback** ⚠️