2012-04-03 10 views
5

ग्राहक आवश्यकता के अनुसार मैं दुर्घटनाग्रस्त होने पर क्रैश रिपोर्ट भेजना चाहता हूं। ऐप को क्रैश किए बिना क्रैश रिपोर्ट भेजने के लिए कैसे संभव है। इसके लिए कोई लिंक या दस्तावेज़ है।एप्लिकेशन क्रैश होने पर क्रैश रिपोर्ट को वेब सेवा पर कैसे भेजूं?

कृपया मुझे ऐसा करने का तरीका सुझाएं। अन्यथा मुझे इसके लिए कोड पोस्ट करें।

धन्यवाद।

+0

कैसे आप क्रैश बिना क्रैश रिपोर्ट मिलेगा !!! ; डी – Maulik

उत्तर

2

जब आप क्रैश के बाद एप्लिकेशन को प्रारंभ करते हैं तो आप अपनी क्रैश रिपोर्ट भेज सकते हैं।

क्रैश रिपोर्ट पढ़ने के लिए 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]); 
} 
+0

उस स्निपेट देने के लिए धन्यवाद। मैंने आपके दिए गए कोड के अनुसार किया है। अब अविकसित त्रुटि के BKAPICLient उपयोग का सामना कर रहा हूँ। BKAPICLient क्या है? इसे कैसे हल करें? @ मौलिक –

+0

@ एस्कोनआर: नमस्ते, यह सिर्फ एक वर्ग है जो मेरे मामले में वेब सेवा कहता है। आपको अपनी विशिष्ट वेब सेवा पर कॉल करने के लिए बस कोड लिखना होगा। बस ! – Maulik

संबंधित मुद्दे