Last active
August 29, 2015 14:03
-
-
Save willrust/1a6f819147e9d2a1c470 to your computer and use it in GitHub Desktop.
Recording view duration as a property in KISSmetrics iOS SDK v2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//In your ViewControllers: (Replace "someViewDuration" with an appropriate name for each view) | |
NSTimeInterval appearedAtTime; | |
- (void)viewWillAppear:(BOOL)animated { | |
appearedAtTime = [[NSDate date] timeIntervalSince1970]; | |
} | |
- (void)viewWillDisappear:(BOOL)animated { | |
int duration = (int)round([[NSDate date] timeIntervalSince1970] - appearedAtTime); | |
[[KISSmetricsAPI sharedAPI] set:@{@"someViewDuration" : @(duration)}]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment