Analytics iOS Collector
How to set up 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
version | platform | player |
---|---|---|
> 1.30.0 | iOS 9+, tvOS 9+ | Bitmovin v2, AVPlayer |
2.0.0 - 2.8.0 | iOS 9+, tvOS 9+ | Bitmovin v3, AVPlayer |
2.9.0 - 2.10.0 | iOS 12+, tvOS 12+ | Bitmovin v3, AVPlayer |
2.11.0 - x.x.x | iOS 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:
BitmovinPlayerCollector
including BitmovinPlayer v3 CollectorAVPlayerCollector
including AVPlayer CollectorAmazonIVSPlayerCollector
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.
.package(url: "https://github.com/bitmovin/bitmovin-analytics-collector-ios", exact: "Version Number")
And then specify the BitmovinAnalytics
package as a dependency of the desired Target. Here is an example of a Package.swift
file:
let package = Package(
...
dependencies: [
...
.package(url: "https://github.com/bitmovin/bitmovin-analytics-collector-ios", exact: "Version Number")
],
targets: [
.target(
name: "<NAME_OF_YOUR_PACKAGE>",
dependencies: [
.product(name: "BitmovinPlayerCollector", package: "bitmovin-analytics-collector-ios"),
// OR
.product(name: "AVPlayerCollector", package: "bitmovin-analytics-collector-ios")
// OR
.product(name: "AmazonIVSPlayerCollector", package: "bitmovin-analytics-collector-ios")
]),
]
...
)
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
- BitmovinPlayerCollector
- AVPlayerCollector
- AmazonIVSPlayerCollector
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.
import CoreCollector
import BitmovinPlayerCollector
import CoreCollector
import AVPlayerCollector
import CoreCollector
import AmazonIVSPlayerCollector
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.
source 'https://github.com/bitmovin/cocoapod-specs.git'
pod 'BitmovinAnalyticsCollector/Core', 'VERSION_NUMBER'
pod 'BitmovinAnalyticsCollector/BitmovinPlayer', 'VERSION_NUMBER'
source 'https://github.com/bitmovin/cocoapod-specs.git'
pod 'BitmovinAnalyticsCollector/Core', 'VERSION_NUMBER'
pod 'BitmovinAnalyticsCollector/AVPlayer', 'VERSION_NUMBER'
source 'https://github.com/bitmovin/cocoapod-specs.git'
pod 'BitmovinAnalyticsCollector/Core', 'VERSION_NUMBER'
pod 'BitmovinAnalyticsCollector/AmazonIVSPlayer', 'VERSION_NUMBER'
Setup the collector
Configuration
First you need to create a config which will provide the collector information about your license but also about the video. 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.
let config = BitmovinAnalyticsConfig(key: "ANALYTICS_LICENSE-KEY")
Collector
Next you need to create our collector and pass it the config
let analyticsCollector = BitmovinPlayerCollector(config: config)
let analyticsCollector = AVPlayerCollector(config: config)
let analyticsCollector = AmazonIVSCollector(config: config)
Attach the collector
As soon as the player is created you have to attach the collector to the player.
analyticsCollector.attachPlayer(player: 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
class CustomDelegate: IVSPlayer.Delegate {.....}
let delegate = CustomDelegate()
player.delegate = delegate
analyticsCollector.attachPlayer(player: 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.
Updated 9 days ago