gpt4 book ai didi

iphone - 当应用程序崩溃时如何向 Web 服务发送崩溃报告?

转载 作者:太空狗 更新时间:2023-10-30 03:54:13 26 4
gpt4 key购买 nike

根据客户要求,我想在应用程序崩溃时发送崩溃报告。如何在不使应用程序崩溃的情况下发送崩溃报告。是否有任何链接或文档。

请建议我执行此操作的方法。否则将代码发给我。

谢谢。

最佳答案

当用户在崩溃后启动应用程序时,您可以发送崩溃报告。

下载 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]);
}

关于iphone - 当应用程序崩溃时如何向 Web 服务发送崩溃报告?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9987924/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com