Summary:
This document contains instructions on installing and using Blue Triangle's software development kit (SDK) for iOS.
Requirements:
- iOS 12.0+
- Xcode 9.0+
Installation:
1. If you don't already have CocoaPods, go ahead and download it.
$ sudo gem install cocoapods
2. Initiate your project with a CocoaPods file:
$ pod init
3. Open the CocoaPods file and add the following:
target 'MyApp' do
pod 'BlueTriangleSDK-iOS', '~> 0.1.0'
end
If you receive the following build-time error, you will need to specify the Cocoapods version:
"Specs satisfying the `BlueTriangleSDK-iOS` dependency were found, but they required a higher minimum deployment target."
The version number can be located on the Cocoapods website: https://cocoapods.org/pods/BlueTriangleSDK-iOS
4. Run Pods install:
$ pod install
Usage:
Setting up the tracker
The BTTracker
class is responsible for global configuration and timer submission. A BTTracker
instance must be initialized and configured before timers can be sent to Blue Triangle for processing. The best place to initialize and configure the tracker is in the AppDelegate
class:
- Objective-C
#import BlueTriangle
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[[BTTracker sharedTracker] setSiteID:@"YOUR_SITE_PREFIX"];
return YES;
}
- Swift
import BlueTriangle
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
BTTracker.shared().setSiteID("YOUR_SITE_PREFIX")
return true
}
Setting up a timer
The BTTimer
class is a simple data object used to time and track fields for Blue Triangle analytic session. There are several pre-established fields which can be set on BTTimer
, including page name, traffic segment, brand value, etc. For a full list, see the constants in BTTimer.h
. BTTimer
inherits from NSObject
and can be passed from class to class allowing for easy field configuration.
- Objective-C
BTTimer *timer = [BTTimer timerWithPageName:@"page-name-1" trafficSegment:@"traffic-segment-1"];
[timer setCampaignName:@"campaign-1"];
[timer setCampaignMedium:@"mobile-ios"];
}
- Swift
let timer = BTTimer(pageName: "page-name-1", trafficSegment: "traffic-segment-s")
timer.setCampaignName("campaign-1")
timer.setCampaignMedium("mobile-ios")
}
Submitting a timer
Timers are submitted to Blue Triangle through an instance of BTTracker
. Any global fields set on the tracker will be applied to the timer before submission. Global fields take precedence over timer fields. Once a timer instance is submitted, the instance can be disposed of.
- Objective-C
...
[[BTTracker sharedTracker] submitTimer:timer];
}
- Swift
...
BTTracker.shared().submitTimer(self.timer)
}
Comments
0 comments
Please sign in to leave a comment.