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

After adding the Google IMA Dynamic Ad Insertion (DAI) SDK to your app and acquiring the required items listed in the Requirements section, you can enable Google DAI ad playback in your iOS app.

<br /> <hr />

## Requirements

  • JWP iOS SDK 4.0.0+

  • [All the JWP iOS SDK requirements](🔗)

  • [Google DAI dependency](🔗)

  • All Google account information listed in the following table

PropertyDescription
**apiKey** NSString<a href="https://support.google.com/admanager/answer/6381445?hl=en&ref_topic=7258182">Stream request API key</a>
**assetKey** NSStringStream asset key, used for live streams You can find this ID in your Google Ad Manager portal. Ask your Google representative for assistance locating this ID.
**cmsID** NSStringContent management system ID of the video, used for video on demand You can find this ID in your Google Ad Manager portal. Ask your Google representative for assistance locating this ID.
**videoID** NSStringIdentifier of the DAI video to be displayed, used for video on demand You can find this ID in your Google Ad Manager portal. Ask your Google representative for assistance locating this ID.

<br /> <hr />

## Specify ad content for a single playlist item

Use the following steps to set up dynamic ad insertion for a single playlist item.



For the following reasons, be sure that the video URL (`videoURL` in our code examples) used to set up the player is consistent with the media content registered with DAI for your `videoID` or `assetKey`:

• If the DAI request fails, the video URL will play as a fallback. • Analytics will be attributed to the correct media item.

  1. Define your Google account information.<br />• If you are displaying a video on demand, define `cmsID` and `videoID`.<br />• If you are displaying a live stream, define `assetKey`.<br /><br />

  2. Instantiate a `JWAdvertisingConfig` object using <a href="https://sdk.jwplayer.com/ios/v4/reference/Classes/JWImaDaiAdvertisingConfigBuilder.html" target="_blank">JWImaDaiAdvertisingConfigBuilder()</a> and the `JWGoogleDAIStream` object.<br />• If you are displaying a video on demand, use `vodStreamInfo(videoID:cmsID:)`.<br />• If you are displaying a live stream, use `liveStreamInfo(assetKey:)`.<br /><br />

  3. If your content is protected, set the `apiKey` property with your Google DAI API key.

  4. Assign the `adConfig` to your `JWPlayerConfiguration`.

In the code examples below, we have added a DAI configuration for a video-on-demand playlist item.

<br /><br />

### Video On Demand



### Live Stream



<br /> <hr />

## Specify ad content for multiple playlist items

Use the following steps to associate new DAI ad content with another playlist item. **You should follow the steps in the [previous section](🔗) first**.

  1. Define your Google account information for each stream.<br />• If you are displaying a video on demand, define `cmsID` and `videoID`.<br />• If you are displaying a live stream, define `assetKey`.<br /><br />

  2. Instantiate a `JWGoogleDAIStream` for each `JWPlayerItem` in your playlist. In our code example, we name this `daiConfig`. This will serve as a default stream if the others cannot be loaded.<br />• If you are displaying a video on demand, use `vodStreamInfo(videoID:cmsID:)`.<br />• If you are displaying a live stream, use `liveStreamInfo(assetKey:)`.<br />• If your content is protected, set the `apiKey` property with your Google DAI API key.<br /><br />

  3. Instantiate a `JWAdvertisingConfig` object using the `JWImaDaiAdvertisingConfigBuilder()` and the `JWGoogleDAIStream` object. This will serve as a default stream if the others cannot be loaded.<br />• If you are displaying a video on demand, use `vodStreamInfo(videoID:cmsID)`.<br />• If you are displaying a live stream, use `liveStreamInfo(assetKey:)`.<br /><br />

  4. Assign the `adConfig` to your `JWPlayerConfiguration`.

### Video On Demand



### Live Stream



<br /> <hr />

## FAQ

<details><summary><strong>Which iOS SDK features are not supported with Google DAI?</strong></summary>

<br />

The following iOS SDK features are not supported with Google DAI:

  • Side-loaded captions

  • Chromecast and Airplay

  • Use of seek API during ad playback

  • Use of playbackRate API

  • <a href="https://developers.google.com/interactive-media-ads/docs/sdks/ios/dai/reference/Classes/IMAStreamRequest#/c:objc(cs)IMAStreamRequest(py)authToken" target="_blank">Stream request Auth token</a>

<br />

</details>

<br />

<!-- Removes the automatic page-to-page navigation at the bottom of the page -->

<style> .rm-Pagination { display: none; } </style>