Skip to main content

Mediation - Facebook Audience

This guide shows how to add mediation through Facebook Audience to your IronSource integration.

Step 1: Set up Facebook Audience Network

Setup Facebook Audience network:

https://developers.ironsrc.com/ironsource-mobile/air/facebook-mediation-guide/#step-1

Step 2: Configure mediation settings in IronSource

There are 3 pieces of Data from the Facebook Audience Network account which need to be inserted into your ironSource Network Setup Module in order for Facebook Audience Network to work correctly in connection with ironSource. See the IronSource guide for more information:

https://developers.ironsrc.com/ironsource-mobile/air/facebook-mediation-guide/#step-7

Step 3: Import the Facebook Audience Network SDK and adapter ANE

The simplest way to install and manage your AIR native extensions and libraries is to use the AIR Package Manager (apm). We highly recommend using apm, as it will handle downloading all required dependencies and manage your application descriptor (Android manifest additions, iOS info additions etc).

However you can choose to install it manually, as you would have done in the past.

Add the Extension

info

Note: All of the commands below should be run in a terminal / command prompt in the root directory of your application, generally the level above your source directory.

If you don't have an APM project setup, expand the guide below to setup an APM project before installing the extension.

Setup APM

Install APM

If you haven't installed apm follow the install guide on airsdk.dev.

Setup an APM project

You will need an APM project for your application.

There are many ways to do this and for more options see the APM documentation. Here we will just initialise a new empty project:

apm init

Check your github token

We use github to secure our extensions so you must have created a github personal access token and configured apm to use it.

To do this create a token using this guide from github and then set it in your apm config using:

apm config set github_token ghp_XXXXXXXXXXXXXXXXXXXXXXXXXXXX

If you don't do this correctly you may find the install will fail.

Install the extension

Install the extension by running:

apm install com.distriqt.ironsource.FacebookAudience

This will download and install the extension, required assets, and all dependencies.

Once complete apm will have created something like the following file structure:

.
|____ assets
| |____ android # android assets
| | |____ audience_network.dex
| |____ ios # ios assets
| | |____ Frameworks
| | | |____ FBAudienceNetwork.framework
|____ ane
| |____ com.distriqt.IronSource.ane # IronSource extension
| |____ com.distriqt.ironsource.FacebookAudience.ane # FacebookAudience mediation extension
| |____ [dependencies]
|____ apm_packages # cache directory - ignore
|____ project.apm # apm project file
  • Add the ane directory to your IDE. See the tutorials located here on adding an extension to your IDE.

  • You will have an assets directory that contains required assets for the installed extensions. You must add the files in the assets/android folder to the root of your Android application package (contains the audience_network.dex file) and the assets/ios folder to the root of your iOS application package (contains the Frameworks folder with required dynamic frameworks).

info

We suggest you use the locations directly in your builds rather than copying the files elsewhere. The reason for this is if you ever go to update the extensions using apm that these updates will be pulled into your build automatically.

Application Descriptor

Updating your application descriptor will insert the required extensionID's and generate the manifest and info additions for your application.

You update your application descriptor by running:

apm generate app-descriptor src/MyApp-app.xml

Change the path (src/MyApp-app.xml) to point to your application descriptor.

caution

This will modify your application descriptor replacing the manifest additions and info additions with the ones generated from apm.

You should backup your application descriptor before running this command to ensure you don't lose any information.

If you need to insert custom data into these sections see the guides for Android and iOS

If you are using an old version of AIR you will need to resign your application following the guide below otherwise your build will likely fail signing validation. AIR 33.1.1.476 or higher do not need this additional step.

Step 4: Additional code required

There is no additional code required.

Step 5: Facebook Additional Settings

CCPA Support

If you are using Facebook adapter 4.3.17+, make sure to follow Facebook Audience Network instructions, as described here. Please note that setting FAN Limited Data Use flag, should be done before initializing ironSource Mediation.

To set this in actionscript call the setDataProcessingOptions() method on the AdSettings instance.

To explicitly not enable Limited Data Use (LDU) mode, use:

FacebookAudience.instance.adSettings.setDataProcessingOptions( [] ); 

To enable LDU for users and specify user geography, use:

  • Country: 1 to indicate USA
  • State: 1000 to indicate California.
FacebookAudience.instance.adSettings.setDataProcessingOptions( ["LDU"], 1, 1000 ); 

To enable LDU for users with geolocation, use:

  • Country: 0 to request that we geolocate that event
  • State: 0 to request that we geolocate that event.
FacebookAudience.instance.adSettings.setDataProcessingOptions( ["LDU"], 0, 0 ); // enable LDU for users with geolocation

iOS 14+ Support

If you are using Facebook adapter 4.3.20+, and building for iOS14+, FAN requires you to set the setAdvertiserTrackingEnabled flag. This allows you to inform Facebook whether to use the data to deliver personalized ads. If the flag is set to false FAN will not be able to deliver personalized ads.

Please note that setting the setAdvertiserTrackingEnabled flag should be done before initializing ironSource Mediation. Learn more about Advertising Tracking Enabled for Audience Network here.

FacebookAudience.instance.adSettings.setAdvertiserTrackingEnabled( true );

Signing your iOS application

This is no longer required since AIR AIR 33.1.1.476

With AIR 27 Adobe partially added the ability to use dynamic frameworks in your iOS application, which works fine with frameworks you control however still has issues with third party frameworks.

Everything will work up to a point, however AIR will incorrectly sign your IPA and it will fail AppStore submission with an error from the Application Loader tool and installing development builds with a signature validation error.

To get around this, before you upload or install your application you will need to run a script to resign your IPA. This script is available in the repository alongside the ANE in the scripts directory.

This script will only work on a macOS machine with Xcode installed and your certificate installed in Keychain

Copy this script to a directory in your development environment.

Firstly edit the script to change the details of the IPA, provisioning profile and signing identity for your application. These details are located at the top of the script.

#####################################
## CONFIG

# You need to set the values below for your application
# We suggest they are full paths to the files.

# The path to the ipa generated from your AIR application packaging
IPA="/path/to/yourApp.ipa"

# The distribution provisioning profile for your application
PROVISIONING_PROFILE="/path/to/profile.mobileprovision"

# The name of the signing identity. You get this by running the following in a terminal
# and selecting the name of your distribution certificate:
#
# security find-identity -v -p codesigning
SIGNING_IDENTITY="iPhone Distribution: XXXXXXXXX (XXXXX)"

Now open a Terminal at the script location. You will need to run the script from this directory.

./resign

This should output a few informational items to the console and then once complete you should have a new IPA file in the directory named: yourApp_resigned.ipa. If there were any errors or warnings displayed, make sure the information above is all correct.

This resigned IPA is the file you should use.