2012-04-03 10 views
5

In base al requisito del cliente, desidero inviare un rapporto di arresto anomalo quando l'app si arresta in modo anomalo. Come è possibile inviare un rapporto di arresto anomalo senza arrestare l'app. Ci sono collegamenti o documenti per questo.Come si invia un rapporto di arresto anomalo al servizio Web quando l'applicazione si arresta in modo anomalo?

Si prega di suggerire il modo di fare questo.otherwise post me codice per questo.

Grazie.

+0

Come Vuoi saperne di crash report senza il Crash !!! ; D – Maulik

risposta

2

È possibile inviare il rapporto di arresto anomalo quando l'utente avvia l'applicazione dopo l'arresto anomalo.

Scaricare crashManagetLib per leggere il rapporto di arresto anomalo.

È possibile scrivere il codice di lettura incidente in didFinishLaunchingWithOptions come: -

- (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]); 
} 
+0

Grazie per aver dato quel frammento. ho fatto secondo il tuo codice dato. Ora sto affrontando l'uso BKAPIClient dell'errore non dichiarato. Che cos'è BKAPIClient? come risolvere questo? @Maulik –

+0

@AsokanR: Ciao, è solo una classe che chiama il servizio web nel mio caso. Hai solo bisogno di scrivere il codice per chiamare il tuo servizio web specifico. Questo è tutto ! – Maulik

Problemi correlati