Last active
December 20, 2015 15:49
-
-
Save PanosJee/6157043 to your computer and use it in GitHub Desktop.
BugSense Helpshift iOS Integration example
This file contains 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 didFinishLaunchingWithOptions at AppDelegate.m | |
[BugSenseController setErrorNetworkOperationsCompletionBlock:^() { | |
NSLog(@"Application crashed with errorId: %ld with an error count since last reset: %d", [BugSenseController lastCrashId], [BugSenseController crashCount]); | |
if ([BugSenseController crashCount] == 1) { // after every crash, customize! | |
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"We're sorry!" | |
message:@"We are aware of the crashes that you have experienced lately. Would you like to tell us more about it?" | |
delegate:self | |
cancelButtonTitle:@"No" | |
otherButtonTitles:@"Yes", nil]; | |
[alertView show]; | |
[BugSenseController resetCrashCount]; | |
} | |
}]; | |
// Add this function to AppDelegate.m | |
- (void)alertView:(UIAlertView *)alertView | |
clickedButtonAtIndex:(NSInteger) buttonIndex{ | |
if (buttonIndex == 1) { | |
[Helpshift setUserIdentifier:@"panosjee"]; | |
[Helpshift metadataWithBlock:^(void){ | |
NSString *burl = [NSString stringWithFormat:@"https://www.bugsense.com/dashboard/project/YOUR_BUGSENSE_API_KEY/errors/%ld", [BugSenseController lastCrashId]]; | |
return [NSDictionary dictionaryWithObjectsAndKeys: burl, @"bugsense_url", | |
[BugSenseController crashCount], "crashCount", nil]; | |
}]; | |
[[Helpshift sharedInstance] reportIssue:self.tabBarController]; // replace with the UIViewController of your choise | |
} else { | |
// Cancel | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment