Step 1 – install Cocoapods if you have not already done so
In terminal execute
$ sudo gem install cocoapods
Step 2 - create an objective c Project if you have not already
Open XCode and click create a new xcode project
Make an iOS app
Make a storyboard interface with objective c as the language
Step 3 - open the directory of your project in terminal and execute pod init to generate a pod file if you do not have one already
Step 4 – edit the pod file created in the directory with vim or another text editor
Add the Blue Triangle pod as a dependency
The version number can be located on the Cocoapods website: https://cocoapods.org/pods/BlueTriangleSDK-iOS
Step 5 – run pod install if this is a new project or pod update if this is an existing project
Step 6 – close xcode and open the new generated workspace
Step 7 – once the workspace is open check to make sure the BlueTriangleSDK-iOS pod files are there
Step 8 – add the foundation framework to the Frameworks-> iOS folder if it is showing up in red like above
Double click pods
Click the plus on Frameworks and Libraries section
Type foundation in the search box to locate Foundation.framework then click add to add the framework
You should see the foundation framework like this now
Drag it to the iOS folder
Delete the red framework
Step 9 – import the BlueTriangleSDK-iOS to your project
Open your app delegate module file
Import the blue triangle header file
#import "AppDelegate.h"
#import <BlueTriangle.h>
Step 10 – add the Blue Triangle tracker to your app delegate
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
[[BTTracker sharedTracker] setSiteID:@"YOUR_SITE_PREFIX"];
return YES;
}
Change YOUR_SITE_PREFIX to your own site prefix
Step 11 – start the Blue Triangle app crash monitoring
Call the track crashes method of the BTTracker class
[[BTTracker sharedTracker] setSiteID:@"YOUR_SITE_PREFIX"];
[[BTTracker sharedTracker] trackCrashes];
Step 12 – create a timer, set up a timer, start it and submit to the portal
//Create the timer with a page name and traffic segment
BTTimer *timer = [BTTimer timerWithPageName:@"YOUR_PAGE_NAME"
trafficSegment:@"YOUR_TRAFFIC_SEGMENT"];
//Set custom fields
//CV1 - CV5 Maps to Custom Variable 1 - 5 in the portal
//CV6 - CV10 Maps to Custom Category 1 – 5 in the portal
//CV11 - CV15 Maps to Variable 6-10 in the Portal
//CN1 - CN20 is Custom Numeric 1 - 20
[timer setField:@"CV1" stringValue:@"YOUR_CUSTOM_VARIABLE"];
//Start the timer
[timer start];
//Do work …..
//Submit the timer
[[BTTracker sharedTracker] submitTimer:timer];
Comments
0 comments
Please sign in to leave a comment.