<img src="https://img.shields.io/badge/iOS-V4-009727?logo=apple" style="float:left"/><br />

The most basic advertising implementation is to run a single VAST ad tag as a pre-roll that runs before each playlist.



  • If you are using IMA ad tags, follow the steps in [Schedule Google IMA ads](🔗).

  • If you are using DAI, follow the steps in [Enable Google DAI playback](🔗).

<br /> <hr />

## Add a pre-roll ad to a player

Use the following steps to add a pre-roll ad to [the player you added to your view](🔗):

  1. Instantiate a `JWAdvertisingConfig` object using the <a href="https://sdk.jwplayer.com/ios/v4/reference/Classes/JWAdsAdvertisingConfigBuilder.html" target="_blank">JWAdsAdvertisingConfigBuilder()</a>. At a minimum, you must assign an ad tag URL to the `tag` property. The ad will be presented as a pre-roll ad.<br /><br />The ad tag can include ad pods and have [custom parameters](🔗) appended to the URL.

<br />

  1. Assign the `JWAdvertisingConfig` object to your `JWPlayerConfiguration` object using the <a href="https://sdk.jwplayer.com/ios/v4/reference/Classes/JWPlayerConfigurationBuilder.html" target="_blank">JWPlayerConfigurationBuilder()</a>.



You can build upon this basic implementation by [adding more ad breaks](🔗) or [defining ad rules](🔗).

<br /> <hr />

## Add multiple ad breaks to a player

Use the following steps to add multiple ad breaks to the previous VAST pre-roll example:

  1. Instantiate a `JWAdvertisingConfig` object using the <a href="https://sdk.jwplayer.com/ios/v4/reference/Classes/JWAdsAdvertisingConfigBuilder.html" target="_blank">JWAdsAdvertisingConfigBuilder()</a>.<br />• Assign an ad tag URL to the `tags` property using <a href="https://sdk.jwplayer.com/ios/v4/reference/Classes/JWAdBreakBuilder.html" target="_blank">JWAdBreakBuilder()</a>.<br />• When defining the `offset` property, refer to documentation of the methods in <a href="https://sdk.jwplayer.com/ios/v4/reference/Classes/JWAdOffset.html" target="_blank">JWAdOffset</a>.

  2. Add the additional `AdBreak` object to the `schedule` array in the <a href="https://sdk.jwplayer.com/ios/v4/reference/Classes/JWAdsAdvertisingConfigBuilder.html" target="_blank">JWAdsAdvertisingConfigBuilder()</a>.



<br />