The iOS Media Player framework allows access to the native media player included with iOS. Datazoom’s framework facilitates native iOS applications to send video playback events based on the configuration created in data pipes.
- Login to Datazoom here: https://app.datazoom.io
- Add a Collector as indicated here: How to add a Collector
- Copy the
config key
that was created at the end of the process
Click the icon indicated below to copy the Configuration Key
You will see this message:
4. Replace the <configuration id from Datazoom>
in Datazoom's DZNativeCollector.framework
file with the Key you copied above.
5. Replace the <url given by Datazoom>
with <https://platform.datazoom.io/beacon/v1/>
6. Replace the <AVPlayer Object>
with your playerInstance
identifier
Installation
Open the terminal and check if Cocoapods is installed in your machine.
pod --version
If the above command returns no version number, then you'll need to install CocoaPods.
sudo gem install cocoapods
After installation, navigate to the Xcode project directory and create a
Podfile
configuration file if not present.pod init
Run the command:
open Podfile
Add the DZNativeiOS framework after
use_frameworks!
in thePodfile
pod 'DataZoomBase', :git => 'https://gitlab.com/datazoom/apple-ios-mobile/datazoom-base-framework' pod 'DZNativeiOS', '0.0.16', :source => 'https://gitlab.com/datazoom/pod-specs.git'
Pull and update the latest Cocoapods pod specs
pod repo update
Install the pods
pod install
- Be sure to close any current Xcode sessions and use `your_project_name.xcworkspace` for this project from now on.
Steps for Swift Language based Applications:
After including the framework file, open the ViewController/View file, where the AVPlayer(native player) is included.
Import the framework using the following command:
import DZNativeCollectorFW
Initialize the framework by passing along the 'Configuration ID', and URL given by Datazoom. Completion handler will return two values, success and error if happened.
DZNativeCollector.dzSharedManager.initDatazoomSDK(configID: <configuration id from Datazoom>, url: <url given by Datazoom>, completion: @escaping (Bool, Error?) -> ())
You can start recording events for your AVPlayer instance using this API call.
DZNativeCollector.dzSharedManager.startRecordingEvents(for: player)
You can also stop recording events of your AVPlayer instance using similiar API call.
DZNativeCollector.dzSharedManager.stoRecordingEvents(for: player)
Run the app and observe the events captured in a Collector, data corresponding to MOBILE/iPhone in Platform, refers to the events tracked from iPhone.
Custom Events & Metadata
Datazoom allows customers to collect custom events and metadata that aren't emitted from the video player.
Custom Metadata
Create an NSDictionary with necessary metadata
let metaData = ["customMetadata":"MetadataValue"]
Add the metadata to DZEventCollector
DZNativeCollector.dzSharedManager.customMetaData(metadata)
Example:func sendCustomMetadata(){ DZNativeCollector.dzSharedManager.customMetaData(: ["customPlayerName": "iOS Native Player"]) }
Custom Events
Send Events like below:
DZNativeCollector.dzSharedManager.customEvents("custom_event_name", metadata: nil)
Example:@objc func buttonPushTouched() { DZNativeCollector.dzSharedManager.customEvents("buttonClick", metadata:["customPlayerName":"NativeiOSPlayer","customDomainName":"datazoom.io"]) }
Steps for ObjectiveC Language based Applications:
After including the framework file, Create a bridging header file, to allow interoperability of languages.
open the ViewController/View file, where the AVPlayer(native player) is included.
Import the following:
#import <AVKit/AVKit.h> #import <AVFoundation/AVFoundation.h> #import <DZNativeCollectorFW/DZNativeCollectorFW.h>
Initialize the swift class in the .h file.
DZNativeConnector *dzObject;
In the .m file, allocate using:
dzSharedManager = [[DZNativeConnector alloc]init]; [dzSharedManager initDatazoomSDK: <configuration id from Datazoom>, url: <url given by Datazoom>];
Run the app and observe the events captured in a Collector, data corresponding to MOBILE/iPhone in Platform, refers to the events tracked from iPhone.
Demo Application
A demo application that shows the usage of this framework is available Here. This can be used to test the DZNativeCollectorFW.Framework
Comments
0 comments
Article is closed for comments.