Tealium Swift APIs - Tealium 1.0.0 - 1.0.1

Tealium Swift APIs - Tealium 1.0.0 - 1.0.1

by on ‎12-01-2016 03:06 PM (175 Views)
FUNCTION NAME DESCRIPTION

init?(config:TealiumConfig)

Library initializer.

getDataManager()

Access the Data Manager for additional options. 

track(title:String, data:[String:AnyObject], completion:((success:Bool, encodedURLString: String, er...

 Primary Track call for events.

track(encodedURLString:String, completion:((success:Bool, encodedURLString: String, error:NSError?)-...

Alternate Track call using prepackaged encoded URL Strings.

 

INIT

init?(config: TealiumConfig)
Parameters Description Example Value
config Required TealiumConfig object

(see TealiumConfig)
// SAMPLE
// Simple Init
let config = TealiumConfig(account: "your_account", profile: "your_profile", environment: "your_environment")
guard let tealium = Tealium(config: config) else {

// Library failed to initialize
return

}

 

DATA MANAGER

The Data Manager instance processes call time data and handles persistent data.

getDataManager()
// SAMPLE
tealium.getDataManager()

 

TRACK 

tealium.track(title:String, data:[String:AnyObject]?, completion:((success:Bool, encodedURLString:String, error:NSError?)->Void?)
Parameters Description
title

Name of event.

data

Optiona [String:AnyObject] dictionary where values are either of type String or [String].

completion

Optional completion block.
// SAMPLE
// Basic track call
tealium.track(title: "someEvent", data: nil, completion: nil)

// With optional data
let optionalData = ["someKey": "someValue"]
tealium.track(title: "someEventWithCustomData", data: optionalData, completion: nil)

// With optional callback
tealium.track(title: "someEventWithCallback", data: nil, completion: { (success: Bool, encodedURLString: String, error: NSError?) in

// Any follow up code here

})

 

TRACK ENCODED URL STRING

This alternate track call is intended for retrying calls initially attempted by the above track(title:data:completion:) method.  EncodedURLStrings from that method's completion handler can be store and the exact same dispatch may be attempted later using this method.

tealium.track(encodedURLString:String, completion:((success:Bool, encodedURLString:String, error:NSError?)->Void)?)
Parameters Description
title

Name of event.

data

Optiona [String:AnyObject] dictionary where values are either of type String or [String].

completion

Optional completion block.
// SAMPLE
// Example retrieval - not actual library function
guard let urlString = somePersistentDispatchStore().firstObject as? String else {
return
}

// Basic track
tealium.track(encodedURLString: urlString, completion: nil)

// With optional callback
tealium.track(encodedURLString: urlString, completion: { (success: Bool, encodedURLString: String, error: NSError?) in

// Example queuing - not actual library function
somePersistentDispatchStore().saveToLastPosition(encodedURLString)

})