Ad Rules

SDK operation modes

Depending on the ad response that the SDK receives from the ad server, it can operate in one or more modes.

Single ad
An ad that can will played at any time when the "start" message is sent to the IMAAdsManager. No special initialization is necessary to play a single ad.
Ad pod
Several ads that will play back to back when "start" message is sent to the IMAAdsManager. No special initialization is necessary to play a single ad pod.
Ad rules
A playlist of ad breaks scheduled at certain times against particular content. The start message is ignored in ad rules mode. There can be several ad breaks scheduled within a single playlist (e.g., pre-roll, mid-roll, post-roll). For further implementation details, see the Ad Rules section below.

Ad rules

IMA iOS SDK v3 supports fully automated ad playlists. This feature will insert ad breaks into the content as specified in Doubleclick for Publishers when trafficking your ads. It also greatly simplifies the video player code necessary to support ad breaks, including pre-rolls, mid-rolls and post-rolls.

  • When trafficking the ads in DFP, it is possible to specify various ad rules like "always play ad break at the beginning of the content" or "play a one minute ad break every 30 minutes of content".
  • When ads are requested, the ad server can return an ad playlist. The SDK processes the playlist and automatically schedules the ad breaks that have been specified.
  • When initializing the AdsManager, an IMAContentPlayhead object is passed in via the initializeWithContentPlayhead:adsRenderingSettings: call. If you are using an AVPlayer to display your content, you can pass an instance of IMAAVPlayerContentPlayhead to the SDK. This object is used to track the progress of the content playback so ad breaks are automatically inserted at the times specified in DFP.

    With AVPlayer:

    IMAContentPlayhead *contentPlayhead =
        [[IMAAVPlayerContentPlayhead alloc]

    Without AVPlayer:

    1. Implement the IMAContentPlayhead interface.
    2. Implement currentTime to return the current time of your video player.
    3. Change your initialization call to the IMAAdsManager to use initializeWithContentPlayhead:self.
  • The IMAAdsManagerDelegate is used to pause and resume the content as ad breaks are played.

Note: When the content has finished playing or the user has stopped playback, be sure to call to call contentComplete on the IMAAdsLoader in order to signal to the SDK that the content is done. The SDK will then play the post-roll ad break, if one has been scheduled. The ALL_ADS_COMPLETED event will be raised when ALL ad breaks have been played. In addition, note that content tracking begins when IMAAdsManager's initializeWithContentPlayhead:adsRenderingSettings method is called and you should always call initializeWithContentPlayhead:adsRenderingSettings before playing content.

Send feedback about...

Need help? Visit our support page.