iOS   发布时间:2022-05-04  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了iphone – 当应用程序崩溃时,如何将崩溃报告发送到Web服务?大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

概述

根据客户要求,我想在App崩溃时发送崩溃报告. 如何在不崩溃应用程序的情况下发送崩溃报告.是否有任何链接或文档. 请建议我这样做的方法.另外发布我的代码. 谢谢. 当用户在崩溃后启动应用程序时,您可以发送崩溃报告. 下载crashManagetLib以阅读崩溃报告. 您可以在didFinishLaunchingWithOptions中编写崩溃读取代码,例如: – - (BOOL)applicati
根据客户要求,我想在App崩溃时发送崩溃报告.
如何在不崩溃应用程序的情况下发送崩溃报告.是否有任何链接或文档.

请建议我这样做的方法.另外发布我的代码.

谢谢.

@H_301_15@解决方法
用户在崩溃后启动应用程序时,您可以发送崩溃报告.

下载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服务?全部内容,希望文章能够帮你解决iphone – 当应用程序崩溃时,如何将崩溃报告发送到Web服务?所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。