# Getting Started

ATTENTION

The Unified Plugin currently only supports CDN Balancer product

Codavel Unified Plugin can be integrated with an iOS app that relies on the following video players:

  • AVPlayer

# How to Install

The installation of the Unified Plugin can be performed via Swift Package Manager or via Cocoapods.

# Swift Package Manager

  1. Open your Xcode project, then go to File > Add Packages

  2. Enter the repository URL: https://repo.plugin.npaw.com/release/plugin-ios.git

  3. On the Dependency Rules, select Exact Version, and type 7.1.2

  4. Choose the target/project in which you want to add the package, then click Add Package

You should now see the UnifiedPluginPkg (and also GCDWebServers) added as a dependency in the Swift Package Manager section of your project.

ATTENTION

If the project does not build, go to the project name in the Project Navigator on the left side, click on your current target under "Targets" and make sure UnifiedPlugin is shown under "Frameworks, Libraries, and Embedded Content" section. If not, click "+" button and choose "UnifiedPlugin", then click "Add".

# Cocoapods

  1. If you don't have Cocoapods installed, install it first by running the following command in your terminal:
gem install cocoapods
1
  1. Navigate to your project's root directory in the terminal and run:
pod init
1

This will create a Podfile in your project directory.

  1. Open the Podfile with a text editor and add the private repository source and the UnifiedPlugin dependency:
source 'https://cdn.cocoapods.org'
source 'https://repo.plugin.npaw.com/release/plugin-ios-cocoapods.git'

target 'YourAppTargetName' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!

  # Pods for YourAppTargetName
  pod 'UnifiedPluginPkg', '7.1.2'
end
1
2
3
4
5
6
7
8
9
10
  1. Save and close the Podfile.

  2. Run the following command in the terminal to install UnifiedPlugin:

pod install
1

This will create an .xcworkspace file. Make sure to open your project using this .xcworkspace file from now on.

  1. Now the UnifiedPlugin should be integrated into your iOS project using Cocoapods.

# Unified Plugin Lifecycle

To initialise the Unified Plugin, first, it needs to be imported on every class it will be used:

import UnifiedPlugin
1

Then, it can be created with the account code provided on the Codavel Panel:

var unifiedPluginInstance = UnifiedPluginInstance.Builder(accountCode: "yourAccountCode")
            .build()
1
2

WARNING

It is important to maintain only one instance of the Unified Plugin throughout the app.

Finally, modify the content-url to play by calling the unifiedPluginInstance.getResource, and pass it to the AVPlayer instance.

// fetch the new URL from Codavel Unified Plugin
guard let url = URL(string: unifiedPluginInstance.getResource(url: "<content-url>")) else { return }

// initialize the player with the new URL
let player = AVPlayer(url: url)

// start the player
let controller = AVPlayerViewController()
controller.player = player
 
present(controller, animated: true) {
    player.play()
}
1
2
3
4
5
6
7
8
9
10
11
12
13

NOTICE

The CDN Balancer module only supports content with the following extensions:

  • mp4
  • m4s
  • ts
  • cmf
  • m3u8
  • mpd

# Next Steps

At this point, your integration of the Codavel Unified Plugin is concluded.

After running your application, you should see your metrics appearing in your Codavel Panel dashboards.

# Further Customizations

The plugin allow you to configure different parameters in your integration, such as the metadata of the video playing. Detailed explanations of these options are available here.

Updated: 7/6/2023, 3:26:38 PM