iOS SDK Migration guide
This guide is intended to help you migrate from the legacy native SDK to our new iOS SDK.
Overview
New repositoriy | – New iOS SDK available on GitHub |
Sample applications | – iOS sample app: Download the sample app on your device and explore the SDK functionalities in a user-friendly UI – Source code: Access the sample app source code, customize it as you wish and easily integrate the SDK into your projects |
Key features | – Remote Player management – iOS 18 support – Verified Google IMA integration – OMSDK support – Sample Player applications & code samples – Fullscreen playback management – Access to Player events and state facilitated – Chromecast support |
Minimum supported versions | Swift 5+ iOS 14+ Xcode 14+ |
Implementation resources
Benefits
Key benefits of the new iOS SDK:
- More customization: The new iOS SDK offers more customization options and greater flexibility in managing Player configurations via the Studio. Embedding and controlling your Players is easier and more efficient thanks to Player IDs.
- Better monetization: The new SDK complies with Google IMA standards and TCF2 to help you handle monetization more effectively
- Improved developer experience: The new SDK provides an easier way to embed and control custom Players, and simplified access to various data
Integration principles
Find the key technical steps required to use our new iOS SDK the best way and benefit from improved functionalities and flexibility compared to the legacy one.
Player customization
While the legacy SDK could only offer limited customization options and control, the new SDK is built around Player IDs. They carry your Player configuration, providing more flexibility and control over the Player’s behavior and appearance without requiring heavy customization within your code:
- Manage from Studio: You can easily create and manage custom Player configurations from the Dailymotion Studio
- Embed Player IDs: Each Player configuration is linked to a unique Player ID which is required for Player initialization in your Android app, and accurate monetization, targeting and attribution
- Optimize with API: Additional customization can be added programmatically using the Player methods, events and state
Learn more about how to create and manage Players from the Studio.
Advertising dependencies
The IMA SDK is already integrated into the new SDK, however, it requires declaring additional dependencies to load the IMA libraries.
The Swift Package Manager can be used to access the SDK. Specify the git URL for Dailymotion iOS SDK: https://github.com/dailymotion/player-sdk-ios
Handling advertising set up
In order to benefit from accurate monetization, make sure to implement the following steps:
- Create a dedicated Player config for your iOS app from your Dailymotion Studio or via the Platform API, and use the generated Player ID in the Player initialization method.
- Publishers in GDPR countries are required to implement a TCF2-registered CMP in their native app to ensure monetization. Collect consent from CMP before loading the Player.
- Implementing
DMPlayerDelegate
is mandatory, see here. - Implement the necessary methods to ensure your application can manage the Player in all contexts, see here.
- Pass in and update custom advertising values. To learn more please see here.
Fullscreen management
The new iOS SDK provides an out-of-the-box fullscreen implementation as well as a custom fullscreen implementation.
See how to implement fullscreen with the new SDK.
Destroy/release Player
The Player instance will be automatically destroyed and removed when there are no more references to the DMPlayerView
object, and when the Automatic Reference Counting (ARC) counter reaches zero.
Mapping
This section provides a mapping of the methods, events and state from the legacy SDK to the new iOS SDK to help you update your integration.
Methods
Legacy iOS methods | New iOS methods |
---|---|
initialize() | Dailymotion.createPlayer(playerId: "PLAYERID", videoId: "VIDEOID", playerParameters: DMPlayerParameters() , playerDelegate: self) |
load(params: String) | loadContent(videoId:playlistId:startTime:) |
play() | play() |
pause() | pause() |
toggleFullscreen() | setFullscreen() Learn more |
unmute() | setMute(mute:) |
mute() | setMute(mute:) |
seek() | seek(to:) |
toggleControls() | No longer supported. Ad and playback controls are now managed in Player configuration. |
Find the complete list of methods for the new iOS SDK.
Events
Description | Legacy events | New events |
---|---|---|
Sent when the Player is ready to accept API commands. Do not try to call functions before receiving this event. | apiready | Managed via createPlayer() method |
Sent the first time the Player attempts to start the playback, either because of user interaction, an autoplay parameter or an API call (e.g play() , load() , etc.). | start | playerDidStart |
Sent when playback of the content video, and eventual post-roll ad video, is completed. | VideoEndEvent | playerDidEnd |
Sent when the Player triggers an error. See all error codes. | error | player(_:didFailWithError:) |
Sent when the Player enters or exits the fullscreen state. | fullscreenchange | – Built-in fullscreen behavior – Custom integration with playerDidRequestFullscreen and playerDidExitFullScreen |
Sent every time a video is ready to play, or started playing (depending on autoplay settings, and their resolution by the browser), or is unable to play (blocked, restricted, unavailable). Listen to this event if you want to defer doing network-heavy and JavaScript-heavy work, to allow the optimal delivery of the first frames of the video to the use. | playback_ready | playerDidCriticalPathReady(_:) |
Sent when the Player starts to seek to another position in the video timeline. | seeking | video(_:didSeekStart:) |
Sent when the Player has completed a seeking operation. | seeked | video(_:didSeekEnd:) |
Sent when a new video has been loaded in the Player. (e.g. after calling load(videoId, [params]) , or at player start-up). | videochange | player(_:didChangeVideo:) |
Sent when the volume or mute state changes. | volumechange | player(_:didChangeVolume:_:) |
Find the complete list of events for the new iOS SDK.
Player state and properties
Legacy SDK
The legacy SDK provided limited access to Player properties: it required specific events to be triggered to be able to retrieve associated Player properties
func player(_ player: DMPlayerViewController, didReceiveEvent event: PlayerEvent) {
switch event {
case .namedEvent(let name, let data):
print("\(name) - \(data)")
case .timeEvent(let name, let position):
print("\(name) - \(position)")
New SDK
The new iOS SDK provides more data with easier access: any value in the Player state can be retrieved at any time using the getState(completion:)
method, without having to rely on specific events.
self.dmPlayerView?.getState(completion: { [weak self] (playerState) in
print("playerIsPlaying : \(playerState?.playerIsPlaying)")
print("videoId : \(playerState?.videoId)")
print("playerError : \(playerState?.playerError)")
})
See full list of available state properties.