Used to Crashlytics, Crash collection function is indeed very powerful, various Crash collection, and real-time to the developers to send mail
For more details see: Tang Qi an article
Domestic Crash of the third party, compared to a lot of low, after all, they are also professional to do Crash, it seems that Twitter has acquired
But have you ever thought about it? A simple Crash collection, more humble than the domestic third party, can achieve basic functions?
First say Crash, the APP is the most deadly problem, the user first reaction can be deleted, and then say to Crash what to do?
Nsdictionary Crash, range over the range of Crash, various Crash
The first thought is that Try Catch, implemented as follows:
@try { //1 nsstring *str = @ "Hello world"; [Str substringfromindex:200]; The program will collapse here } @catch (NSException *exception) { //2 NSLog (@ "%s\n%@", __function__, exception); @throw exception;//Can not be thrown out of the exception} @finally { //3 NSLog (@ "Finally, I still execute"); } 4 //will be executed here NSLog (@ "Yeah,pass");
A bit of meaning, convenient debugging, a lot of convenience for data model processing, but there are always unexpected crash
At the same time also see a basic data type, KVO Crash processing of third party also good recommended under Durexkit
Http://code4app.com/ios/DurexKit%E5%AE%89%E5%85%A8%E5%B7%A5%E5%85%B7%E5%8C%85/5325b421933bf0463d8b49ec
Back to the point, the domestic Crash collection is what it looks like, such as Crash log, to a AVOs Crash log
Can you achieve it? From the message view, the basic and AVOs Log consistent can be achieved simple crash collection
The code is as follows:
-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (Nsdictionary *) launchOptions { Override point for customization after application launch. Preferably placed before other code Nssetuncaughtexceptionhandler (&uncaughtexceptionhandler); NSString *str = @ "abc"; [Str substringfromindex:111]; The program will collapse here and return YES;
void Uncaughtexceptionhandler (NSException *exception) { /** * Get exception crash information */ Nsarray *callstack = [ Exception Callstacksymbols]; NSString *reason = [exception reason]; NSString *name = [exception name]; NSString *content = [NSString stringwithformat:@ "======== exception error Report ========\nname:%@\nreason:\n%@\ncallstacksymbols:\n %@ ", Name,reason,[callstack componentsjoinedbystring:@" \ n "]; /** * send abnormal crash information to developer Mail * / nsmutablestring *mailurl = [nsmutablestring string]; [Mailurl appendstring:@ "mailto:[email protected]"; [Mailurl appendstring:@] subject= program abnormal crash, please cooperate with send exception report, thank you for your cooperation! "]; [Mailurl appendformat:@ "&body=%@", content]; Open Address nsstring *mailpath = [Mailurl stringbyaddingpercentescapesusingencoding:nsutf8stringencoding]; [[UIApplication sharedapplication] Openurl:[nsurl Urlwithstring:mailpath];}
The contents of the message are as follows, the basic realization of the AVOs crash collection function, collection device model, system code:
[IOS] Crash collection implementation similar to Leancloud