# Server-side ad insertion (SSAI) for iOS Server-side ad insertion (SSAI) allows you to serve ads that are dynamically inserted into video content at the server level before content is delivered to the viewer's device. This is in contrast to client-side ad insertion (CSAI), where the viewer's device inserts ads during playback. Ad insertion on the server side is typically in real-time or near real-time. SSAI offers several advantages over CSAI, such as: * Server-level ad insertion makes advertisements less susceptible to ad blockers used by viewers, resulting in higher delivery rates. * SSAI allows for more precise ad targeting based on real-time viewer data, leading to higher ad relevance and engagement. * Ads are seamlessly integrated into the video stream. Therefore, viewers experience smooth playback without buffering or quality degradation during ad transitions. This page explains how to configure the Wowza Flowplayer Apple SDK to work with Google's Interactive Media Ads Dynamic Ad Insertion (IMA DAI) SDK. ## Before you start For Google's IMA DAI integration to work with the Wowza Flowplayer Apple SDK for iOS or tvOS, you need the following: * Access to a Google Ad Manager 360 Advanced account and a contract with Google to enable DAI. * To use IMA DAI pod serving, you must also be working with a pod-serving partner. * Make sure to download Google IMA SDK iOS 3.20.0 (exact version) and Google IMA SDK tvOS 4.11.1 (exact version) depending on your project. You need this dependency to integrate multimedia ads into the player and your application. * Review Google's IMA DAI SDK for iOS and IMA DAI SDK for tvOS reference documentation. * If you're configuring ads with Wowza Video platform media, ensure you have access to Wowza Video to complete the advertising configuration. You must also generate a player token in Wowza Video and [set up the player](/docs/wowza-flowplayer/apple-sdk/configure-your-application/#set-an-access-token) to use this token. Info DAI Pod Serving is a beta intended for Ad Manager publishers and video technology partners who either have an in-house manifest manipulation service or are currently using third-party manifest manipulation that's already integrated with DAI. ## Configure DAI ads with Wowza Video If you're using the [MediaOVP](/docs/wowza-flowplayer/apple-sdk/set-up-the-player/#add-wowza-video-media) media type to load your video, you can configure DAI media and advertisements in Wowza Video. This section describes how to set up DAI ads to load with your video content from Wowza Video, then use those configurations with the Apple SDK. At this time, we only support Google's VOD full service solution in Wowza Video. embed After the previous steps, you can use the `mediaId` and `playerId` values to load the Wowza Video media. These example values are placeholders and must be replaced with your own: ```swift let platformMedia = MediaOVP(mediaId: "[your-media-id]", playerId: "[player-configuration-id]") let player.load(ovp: platformMedia) ``` ## Configure DAI media programmatically embed ### Get pod-serving stream data Pod-serving scenarios require the `DAIStreamPodData` structure to fetch the content URL and associated subtitles when you're working with a manifest manipulator or third-party partner. This struct takes the required properties in the following table. | Property | Description | | --- | --- | | `streamURL`*String* | Holds the URL of the video stream as provided by a manifest manipulator or third-party partner using pod serving. For DAI live pod serving, a `stream_id` query parameter is appended to the URL. If the `streamURL` for a DAI live pod request already contains a `stream_id` parameter, it's overwritten by the stream ID received from the DAI SDK. | | `subtitles`*Array* | Holds an optional array of dictionaries, with each dictionary representing a set of subtitles for a specific language. If present, the subtitles are loaded with the stream. | ### DAI VOD stream parameters embed ### DAI live stream parameters embed ## Listen for DAI events When working with DAI stream content, you can use the delegate method or the NotificationCenter class to consume player-emitted events. See the [FlowplayerDAIDelegate](/docs/wowza-flowplayer/apple-sdk/listen-for-events/#flowplayerdaidelegate) or the [DAI stream notifications](/docs/wowza-flowplayer/apple-sdk/listen-for-events/#dai-stream-notifications) sections for information about capturing DAI stream events, such as stream errors, stream state changes, and stream ad playback progress. ## Handle DAI stream errors If an error is related to a DAI-stream, it returns the `AdError` object. For error descriptions, see the [AdError](/docs/wowza-flowplayer/apple-sdk/handle-errors/#aderror) custom error type. ## Supported features When using the Wowza Flowplayer Apple SDK, you can take advantage of the supported DAI features described in this section. These DAI features can be implemented when adding the player to your iOS or tvOS applications. ### Bookmarking In the Google IMA DAI SDK, bookmarking refers to the capability of saving a user's viewing session progress. This feature can only be used with VOD full-service and pod-serving DAI content, where users pause or stop watching and then resume later at their last watched position. Bookmarking can be especially important in scenarios where content includes dynamically-inserted advertisements. If a user stops watching in the middle of an ad break, bookmarking ensures they can resume playback without having to re-watch previously seen ads. Overall, bookmarking provides a seamless experience and continuity in video playback so users can pick up where they left off. #### Example The following example loads a DAI VOD full service stream and sets the `bookmark` value to 20 seconds. Therefore, if a 10 second pre-roll ad was part of the DAI stream, the player would account for the ad time and start the DAI stream at 30 seconds. ```swift // Ensure you have a valid backup stream URL or set it to nil if not available let backupStreamURL: URL? = URL(string: "https://example.com/backup") // Create DAIStreamVOD object and define parameters let stream = DAIStreamVOD( contentSourceID: "[your-content-source-id]", videoID: "[your-video-id]", // Skip to 20 seconds in the DAI stream and also account for any ad time bookmark: 20, backupStream: backupStreamURL ) // Create MediaDAI object let media = MediaDAI(stream: stream) // Load the media into the player let player.load(dai: media) ``` For more, see Google's IMA DAI SDK for iOS bookmarks or IMA DAI SDK for tvOS bookmarks topics. ### Snapback The snapback feature is automatically integrated into the Wowza Flowplayer Apple SDK when you play a DAI VOD full-service or pod-serving stream. It doesn't apply to DAI live-stream content. There's no additional configuration to use it. With the snapback feature, you can make sure that if dynamic ad insertion is enabled for the stream, viewers cannot seek past your mid-roll ads. For example, when a user seeks past an ad break, you can take them back to the start of that ad break. You can then return them to their seek location after the ad break is finished. Overall, the snapback feature ensures that any ads that were scheduled to play are appropriately handled. For more, see Google's IMA DAI SDK for iOS snapback or IMA DAI SDK for tvOS snapback topics.