Redirect Notice

Redirect Notice

The page you requested has been relocated to Player Docs.

Facebook Audience Network

This module’s goal is to ease the integration of Facebook Audience Network and the Akamai AMP Player for iOS. With just a few steps we can achieve this integration, let’s see how.

Installation

Just import the AmpFBAudienceNetwork.framework and the FBAudienceNetwork.framework into your project. For more information check out the AmpCore’s documentation.

Note: Make sure to add the frameworks as Embedded Binaries or you’ll get an error about a missing image.

How to Use

Let’s first import the required frameworks:

import AmpCore
import AmpFBAudienceNetwork

Then, let’s add the related variables in our UIViewController:

var ampPlayer: AmpPlayer!
var ampFBAudienceNetwork: AmpFBAudienceNetwork!

And it’s time to instantiate them now in your viewDidLoad function:

ampPlayer = AmpPlayer(parentView: self.view)
ampPlayer.registerObserver(self)
ampPlayer.setLicense(license)
ampFBAudienceNetwork = AmpFBAudienceNetwork(player: ampPlayer, placementID:"YOUR_PLACEMENT_ID", adBreaksAtSeconds:[timestamps array in seconds])
ampPlayer.play(url: url)

Ads management

The Facebook Audience Network ads can be managed through several methods provided to the user by using the following methods.

Methods Parameters Usage
enablePreroll enabled:Bool Enables the playback of one preroll ad
enablePostroll enabled:Bool Enables the playback of one postroll ad
requestAd Requests one ad

The callbacks onAdStarted(ad: AdInfo?) and onAdEnded(ad: AdInfo?) must be used whenever ads start and end events are required. The position attribute of the ad object returns:

Value Ad position
0 preroll
1 midroll
2 midroll

Midrolls cannot be requested within the last ten seconds of a video on demand when the postroll is enabled.