<img src="https://img.shields.io/badge/iOS-V4-009727?logo=apple" style="float:left"/><br />
After adding the Google IMA SDK to your app and acquiring the required items listed in the Requirements section, you can schedule Google IMA ads in your iOS app.
<br /> <hr />
## Requirements
[All the JWP iOS SDK requirements](🔗)
[Google IMA dependency](🔗)
<br /> <hr />
## Scheduling Ad Breaks
### Add a pre-roll ad to a player
If you use the IAB Open Measurement Interface Definition (OMID) and run Google IMA ads, all custom video controls that overlay the media element must be [registered as friendly obstructions](🔗).
Use the following steps to add a pre-roll ad to [the player you added to your view](🔗):
Use <a href="https://sdk.jwplayer.com/ios/v4/reference/Classes/JWAdBreakBuilder.html" target="_blank">JWAdBreakBuilder()</a> to instantiate a `
JWAdBreak
` object. The `JWAdBreak
` object defines the ad tag and the pre-roll offset.<br /><br />The ad tag can include ad pods and have [custom parameters](🔗) appended to the URL.
If the ad tag you are using is a VAST VMAP file, follow the steps to [Schedule ads using a VMAP file](🔗).
<br />
Use <a href="https://sdk.jwplayer.com/ios/v4/reference/Classes/JWImaAdvertisingConfigBuilder.html" target="_blank">JWImaAdvertisingConfigBuilder()</a> and the `
JWAdBreak
` to instantiate a `JWImaAdvertisingConfig
`. This object creates an IMA configuration to play a pre-roll ad.
<br />
Use <a href="https://sdk.jwplayer.com/ios/v4/reference/Classes/JWPlayerConfigurationBuilder.html" target="_blank">JWPlayerConfigurationBuilder()</a> to instantiate a `
JWPlayerConfiguration
` that associates the `JWImaAdvertisingConfig
` with the player.
<br /> <br />
### Add multiple ad breaks to a player
Use the following steps to add multiple ad breaks to the previous VAST pre-roll example:
Use <a href="https://sdk.jwplayer.com/ios/v4/reference/Classes/JWAdBreakBuilder.html" target="_blank">JWAdBreakBuilder()</a> to instantiate another `
JWAdBreak object
`.Add the additional `
JWAdBreak
` to the schedule array of `JWImaAdvertisingConfig()
`.
<br /> <br />
### Schedule ads using a VMAP file
If you use the IAB Open Measurement Interface Definition (OMID) and run Google IMA ads, all custom video controls that overlay the media element must be [registered as friendly obstructions](🔗).
<br />
A VAST <a href="https://www.iab.com/guidelines/vmap/" target="_blank">video multiple ad playlist (VMAP)</a> file. According to the IAB, "VMAP enables the content owner to define the ad breaks within their content, including the timing for each break, how many breaks are available, what type of ads and how many are allowed in each break".
Use the following steps to schedule ads using a VMAP file:
Instantiate a `
JWImaAdvertisingConfig
` object using the <a href="https://sdk.jwplayer.com/ios/v4/reference/Classes/JWImaAdvertisingConfigBuilder.html" target="_blank">JWImaAdvertisingConfigBuilder()</a>, setting the `tag
` property with the URL of the VMAP file.Using the `
JWImaAdvertisingConfig
` you created and <a href="https://sdk.jwplayer.com/ios/v4/reference/Classes/JWPlayerConfigurationBuilder.html" target="_blank">JWPlayerConfigurationBuilder()</a>, instantiate a `JWPlayerConfiguration
`.
<br />