Meta Audience Network

In this article, you will learn how to configure Meta Audience Network as third party demand party in your app.

The Nimbus SDK will automatically import the Meta Audience Network SDK and handle injecting all the necessary parameters into the outgoing NimbusRequest after initialization.

Before getting started, follow the steps to create and setup your Meta account.

How it works

The SDK will automatically inject the bidder token and app id into the outbound request to Nimbus when using the NimbusAdManager. When the FANDemandProvider is initialized it will fetch the bidder token in the background for use on future requests and install the FANAdRenderer to render any wins from Meta.

Installation

Include the Nimbus Extension for Meta Audience Network in your build.gradle(.kts) file. If the Meta Audience Network SDK is not already included in your application the Nimbus Extension will import it for you.

dependencies {
    implementation("com.adsbynimbus.android:extension-facebook:2.+")
}

Update or add network_security_config

Add the following to your network_security_config file or create a new one and link to it from the application tag in your AndroidManifest.xml

<?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>

Data Privacy

Meta has instructions for setting up Data Processing Options prior to Nimbus's initialization. Please refer to this link to set it up.

Configure the SDK to include Meta Audience Network Demand

Initialize the FANDemandProvider with your app id provided to you from Meta.

lateinit var applicationContext: Context
FANDemandProvider.initialize(applicationContext, "your_meta_app_id")

Requesting Meta Audience Network Ads

Meta Audience Network ads are automatically included in the auction if the FANDemandProvider has been initialized and placement ids for Meta Audience Network have been setup in Nimbus.

Meta Audience Network banner and native units can be embedded in a layout and must use the following call:

nimbusAdManager.showAd(NimbusRequest.forBannerAd(...), layout, listener)

Interstitial and Rewarded video

Meta Audience Network interstitial and rewarded video ads are full screen takeovers and must use the following call:

nimbusAdManager.showBlockingAd(NimbusRequest.forInterstitialAd(...), activity, listener)

Customize Meta Audience Network rendering (Optional)

If you would like to customize the rendering of the FANAdRenderer, you can instantiate your own delegate and override the customViewForRendering() method to create a custom native ad layout. Please note the publisher is responsible for setting all of the relevant information on the views created in a custom layout.

// To Customize Native Rendering
FANAdRenderer.setDelegate(FANAdRenderer.Delegate {

    override fun customViewForRendering(container: ViewGroup, nativeAd: NativeAd) {
        TODO("Return native ad view")
    }
})

Testing the integration

To test the integration, follow steps from this guide to setup a device for receiving test integrations.

In order to force Nimbus to return a Meta Audience Network test ad you must enable `testMode` and set `forceTestAd` to true before requesting/rendering an ad.

Nimbus.testMode = true
FANDemandProvider.forceTestAd = true

Please remember to turn testMode and forceTestAd OFF for production

Please work with your Nimbus account manager to ensure that the placements have been added in the Nimbus dashboard and are not paused.

After completing the steps above, your app will be ready to start showing Facebook Ads in your app.

Last updated