Skip to content

Instantly share code, notes, and snippets.

@PanosJee
Last active December 20, 2015 15:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PanosJee/6157043 to your computer and use it in GitHub Desktop.
Save PanosJee/6157043 to your computer and use it in GitHub Desktop.
BugSense Helpshift iOS Integration example
// 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