Skip to content

Instantly share code, notes, and snippets.

@PanosJee
Last active Dec 20, 2015
Embed
What would you like to do?
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