In the development process, we sometimes leave a bug, users in the use of our app, sometimes there will be a flashback, this time we can let users send us email, so that our developers more high-speed status to the location of the bug. Solve the problem in the quickest time. Also improve the user experience at the same time.
in the APPDELEGATE.M file, add code such as the following:
01 |
NSUncaughtExceptionHandler* _uncaughtExceptionHandler = nil; |
02 |
void UncaughtExceptionHandler(NSException *exception) { |
03 |
NSLog(@ "CRASH: %@" , exception); |
04 |
NSLog(@ "Stack Trace: %@" , [exception callStackSymbols]); |
07 |
NSArray *stackArray = [exception callStackSymbols]; |
09 |
NSString *reason = [exception reason]; |
11 |
NSString *name = [exception name]; |
13 |
NSString *syserror = [NSString stringWithFormat:@ "mailto://[email protected]?subject=bug报告&body=感谢您的配合!<br><br><br>" |
14 |
"Error Detail:<br>%@<br>--------------------------<br>%@<br>---------------------<br>%@" , |
15 |
name,reason,[stackArray componentsJoinedByString:@ "<br>" ]]; |
17 |
NSURL *url = [NSURL URLWithString:[syserror stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; |
18 |
[[UIApplication sharedApplication] openURL:url]; |
And then in- ( BOOL ) Application: ( uiapplication *) Application didfinishlaunchingwithoptions: (nsdictionary *) Add code to the Launchoptions method:
2 |
_uncaughtExceptionHandler = NSGetUncaughtExceptionHandler(); |
5 |
NSSetUncaughtExceptionHandler(&UncaughtExceptionHandler); |
iOS catches exceptions and sends pictures for easy resolution of bugs