- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
NSSetUncaughtExceptionHandler(&UncaughtExceptionHandler);
return
YES;
}
void UncaughtExceptionHandler(NSException *exception) {
NSArray *callStack = [exception callStackSymbols];
NSString *reason = [exception reason];
NSString *name = [exception name];
NSString *content = [NSString stringWithFormat:@
"========异常错误报告========
name:%@
reason:
%@
callStackSymbols:
%@"
,name,reason,[callStack componentsJoinedByString:@
"
"
]];
NSMutableString *mailUrl = [NSMutableString string];
[mailUrl appendString:@
"mailto:test@qq.com"
];
[mailUrl appendString:@
"?subject=程序异常崩溃,请配合发送异常报告,谢谢合作!"
];
[mailUrl appendFormat:@
"&body=%@"
, content];
NSString *mailPath = [mailUrl stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:mailPath]];
}