Repository: <https://github.com/bitmovin/bitmovin-analytics-collector-ios>

Docs Referece: <https://cdn.bitmovin.com/analytics/ios/3.0.0/docs/index.html>

# How to set up the iOS Collector

Bitmovin Analytics enables you to get useful insights into the video usage in your apps. It offers a simple integration with our Bitmovin Player and others.

For more information on how to setup the Bitmovin Player, go to the [Player Getting Started Guide](🔗).

## Platform Support

versionplatformplayer
> 1.30.0iOS 9+, tvOS 9+Bitmovin v2, AVPlayer
2.0.0 - 2.8.0iOS 9+, tvOS 9+Bitmovin v3, AVPlayer
2.9.0 - 2.10.1iOS 12+, tvOS 12+Bitmovin v3, AVPlayer
2.11.0 - 2.12.1iOS 14+, tvOS 14+Bitmovin v3, AVPlayer, Amazon IVS
3.0.0 - 3.x.xiOS 14+, tvOS 14+Bitmovin v3, AVPlayer, Amazon IVS

SPM support since `2.8.0`

## Add the SDK to your project

### SwiftPM

[Swift Package Manager](🔗) is a tool for managing the distribution of Swift frameworks. It integrates with the Swift build system to automate the process of downloading, compiling, and linking dependencies.

We support Swift Package Manager since `2.8.0`

We provide three products:

  • `BitmovinCollector` including BitmovinPlayer v3 Collector

  • `AVFoundationCollector` including AVPlayer Collector

  • `AmazonIVSCollector` including the Amazon IVS Player Collector

#### Using Xcode

To integrate using Xcode 13, open your Project file and specify it in `Project > Package Dependencies` using the following URL:

`<https://github.com/bitmovin/bitmovin-analytics-collector-ios>`

#### Using Package.swfit

You can also add us manually. For that you need to add the following package as a dependency to your `Package.swift` and replace the `Version Number` with the desired version of the SDK.



And then specify the `BitmovinAnalytics` package as a dependency of the desired Target. Here is an example of a `Package.swift` file:



#### Limitations

Executing `swift build` from the command line is currently not supported. Open the Package in Xcode if you are developing another Package depending on BitmovinAnalytics.

#### How to import the collector

We have split the BitmovinAnalytics package into 4 targets

  • CoreCollector - including shared code for all collectors

  • BitmovinCollector

  • AVFoundationCollector

  • AmazonIVSCollector

if you are working with our Collectors you need to add at least `import CoreCollector` because many Classes are relocated to that package. Going further you need to import the corresponding Collector package for your player.



### CocoaPods

BitmovinAnalyticsCollector is available through [CocoaPods](🔗). We depend on `cocoapods` version `>= 1.4`.

Add the following lines to the Podfile of your project while replacing `VERSION_NUMBER` with the desired version of the SDK. All available versions are listed in the [cocoapod repository](🔗).

Run `pod repo update` to add the newly added source and run `pod install` to install it.



## Setup the collector

### Configuration

First you need to create a config and metadata which will configure the collector and provide some information used during the lifetime of this collector instance. For more information checkout our [Configuration Guide](🔗).

Please replace `ANALYTICS_LICENSE_KEY` with a license key from your account. Please checkout [How to set up](🔗) to learn more about how to get to your analytics license.



### Collector

Next you need to create our collector and pass it the config and metadata



### Attach the collector

As soon as the player is created you have to attach the collector to the player.



#### Amazon IVS Collector

In order to get notified by the player events we will set an internal class to be the delegate of the player. If you also want to get notified by the player event we ask you to set your Delegate before you attach the collector to the player. We will keep a weak reference to your delegate and call it once our code is finished. Once you call `detach()` on the collector we reassign your delegate to the player



## Check Statistics in Dashboard

After the setup is done there is nothing more to do. Events are recorded automatically and you can head over to the [analytics dashboard](🔗) to see statistics.