Mobile 170: Getting Started with Swift - 1.0.0 - 1.0.1

Mobile 170: Getting Started with Swift - 1.0.0 - 1.0.1

by on ‎12-01-2016 02:53 PM (367 Views)

To integrate the Tealium Swift Library:


  1. Add to Project
  2. Initialize
  3. Track Events
  4. Additional Info

0. Requirements


- Swift 2+


1. Add to Project:


Import the Tealium folder into your project. The library is made up of the following .swift files:


Note: The above classes with links are those with public APIs.


2. Initialize:

To initialize, first create a TealiumConfig object with the account requirements, then pass the configuration object as an argument to the Tealium initializer.  See the API documentation for additional config options:


// Minimum setup
var config = TealiumConfig(account: "your_account", profile: "your_profile", environment: "dev_qa_or_prod")
Tealium tealium = Tealium(config: config)


3. Track events:


Track any events that occur in the app such as button clicks or lifecycle.


// Basic track call
tealium.track("someUniqueTitle", nil, nil);

// With optional data
let data = [ "someKey" : "someValue" ]
tealium.track("someUniqueTitle", data, nil);

// With optional callback
tealium.track("someUniqueTitle", data: null) { (success, encodedURLString, error) in
// Any monitoring or follow-up code here


4. Additional Info