根據客戶要求我想發送崩潰報告當應用程序崩潰。 如何發送崩潰報告,而不會崩潰的應用程序。是否有任何鏈接或文件。如何在應用程序崩潰時向Web服務發送崩潰報告?
請建議我這樣做的方式。另外我的代碼爲此。
謝謝。
根據客戶要求我想發送崩潰報告當應用程序崩潰。 如何發送崩潰報告,而不會崩潰的應用程序。是否有任何鏈接或文件。如何在應用程序崩潰時向Web服務發送崩潰報告?
請建議我這樣做的方式。另外我的代碼爲此。
謝謝。
當用戶在崩潰後啓動應用程序時,您可以發送您的崩潰報告。
下載crashManagetLib來閱讀崩潰報告。
您可以在didFinishLaunchingWithOptions
喜歡寫你的崩潰閱讀代碼: -
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[self checkCrash];
}
// To check Crash and attach the crash file to Email
- (void) checkChrash
{
//code for the application crash report.
NSFileManager *file = [NSFileManager defaultManager];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *dir = [paths objectAtIndex:0];
NSString *errorReportPath = [[dir stringByAppendingPathComponent:@"crash_report.plcrash"] retain];
//Call Crash Manager if apps is crashed
[[CrashManager sharedInstance] manageCrashes];
[[CrashManager sharedInstance] setCrashDelegate:self selector:@selector(notifyException:stackTrace:)];
//Mail Dialog is display if apps is crashed
NSString* errorReport = [CrashManager sharedInstance].errorReport;
if ([file fileExistsAtPath:errorReportPath])
{
if(nil != errorReport)
{
// log out from facebook.
[[NSUserDefaults standardUserDefaults] removeObjectForKey:@"TOKEN"];
NSString *crashResponce = [BKAPIClient sendCrashReportByMethod:aCrashReport WithErrorLog:errorReport];
NSLog(@"%@",crashResponce);
if ([crashResponce isEqualToString:@"True"])
{
NSLog(@"Crash Report has been sent !");
}
[file removeItemAtPath:errorReportPath error:nil];
}
}
[errorReportPath release];
}
// For stack trace of crash
- (void) notifyException:(NSException*) exception stackTrace:(NSArray*)stackTrace
{
// Oh no! We crashed!
// Time to output some stuff to the console.
// Note: Any EXC_BAD_ACCESS crashes (such as accessing a deallocated object) will
// cause the app to close stdout, so you won't see this trace in such a case.
NSLog(@"Exception:\n%@\n", exception);
NSLog(@"Full Trace:\n%@\n", [[StackTracer sharedInstance] printableTrace:stackTrace]);
NSArray* intelligentTrace = [[StackTracer sharedInstance] intelligentTrace:stackTrace];
NSLog(@"Condensed Intelligent Trace:\n%@", [[StackTracer sharedInstance] condensedPrintableTrace:intelligentTrace]);
}
感謝您給出該片段。我已按照您的給定代碼完成。現在我面臨BKAPIClient使用未聲明的錯誤。什麼是BKAPIClient?如何解決這個問題? @Maulik – 2013-04-17 06:35:27
@AsokanR:嗨,它只是一個在我的情況下調用Web服務的類。您只需編寫代碼來調用您的特定Web服務。而已 ! – Maulik 2013-04-17 06:45:19
你怎麼會得到崩潰報告沒有崩潰! ; D – Maulik 2012-04-03 06:12:21