Google IMA / DAI

The AmpIMA plugin offers a quick way to integrate AmpPlayer with the Interactive Media Ads by Google. This plugin will handle the interaction between the AmpPlayer with the plugin as well as the ads insertion or DAI stream playback.

If you desire to check out a basic implementation please refer to our application samples:

Adding the Plugin to the Xcode project

Manual Installation

To manually install the plugin you’ll need to download our latest distribution. You’ll have to look for the AmpIMA.framework and the AmpCore.framework. You will also need the Google IMA SDK for iOS, you can download it on the iOS release page.

For tvOS you should include the AmpCoreTV.framework and the AmpIMATV.framework. The Google IMA SDK for tvOS will be required as well, you can download it on the tvOS release page.

The latest version of the Google IMA SDK used by this plugin is 3.11.4 on iOS and 4.2.2 on tvOS . Newer versions may be used, but you may run into unexpected errors until an update is released.

After aquiring the frameworks you can just drag them to you Xcode project directory.

manual installation 1

The last step, is to mark every imported framework for Embed & Sign in the project’s general tab.

manual installation 2


If you don’t have CocoaPods installed, refer to the CocoaPods documentation. To use CocoaPods, first create a Podfile in the directory containing the Xcode project. For the AmpIMA plugin, the Podfile should look like this:

target "ProjectName" do


  pod 'AmpCore'
  pod 'AmpIMA'
  pod 'GoogleAds-IMA-iOS-SDK'


Once you have added the Podfile just run the command pod install --repo-update in the directory it’s located. Once the command has been completed you should se a new .xcworkspace file in your folder. Now you can start integrating the library.


You need a working implementation of the AmpPlayer before using this plugin. If you need the implementation guide for AmpPlayer please refer to our documentation.


The first step is to import the AmpIMA plugin. In the most likely scenario you will need the AmpCore library, and you may need the Google IMA SDK in specific cases.

import AmpCore
import AmpIMA
import GoogleInteractiveMediaAds

Creating a new instance

To use this plugin you should first initialize it. You need to specify the player being used as well as the view were the ads will be displayed.

let manager = AmpIMAManager(ampPlayer: player, videoView: player.playerView!)
Do not create multiple instances of the AMPIMAManager. This could create unwanted behaviors since it wouldn’t be following Google’s recomendation against intancing more than one IMAAdsLoader.

Requesting DAI streams

To request a DAI live or VoD stream you won’t need to call the method. Instead use thismethod for requesting the DAI streams:

Live Stream
manager.requestLiveStream(assetkey: "sN_IYUG8STe1ZzhIIE_ksA")
VoD Stream
manager.requestVodStream(contentSourceID: "2528370", videoID: "tears-of-steel")
You can also add a fallback URL on this methods so that if the stream couldn’t be loaded the fallback will still be played.

Requesting IMA ads

To request IMA ads just send your Ad Tag provided by Google to this method.

manager.requestImaAds(adTagUrl: adsUrl)

This will request the ads and display them at the proper time.

Listening to events

This plugin will automatically hook the events from the IMA SDK, both client-side ads and DAI streams, and send the proper AMPPlayer Events. However, in case you want to handle yourself some of the events on IMA, we provide the means to do this by passing a valid delegate to the manager.

manager.imaDelegate = self
manager.daiDelegate = self

Additional Information

This guide was written on 4/27/2020 and it’s last revision was made on 4/27/2020. If you need any additional support please contact us through our offical support email.