应用崩溃邮件通知

时间:2014-04-30 01:30:17   收藏:0   阅读:377

利用 NSSetUncaughtExceptionHandler,当程序异常退出的时候,就给指定的邮箱发送邮件,邮件内容包括发生异常时候的详情。代码如下:

 
bubuko.com,布布扣
void UncaughtExceptionHandler(NSException *exception) {
NSArray *arr = [exception callStackSymbols];
NSString *reason = [exception reason];
NSString *name = [exception name];
NSString *urlStr = [NSString stringWithFormat:@"mailto://suifeng_89@163.com?subject=bug报告&body=感谢您的配合!<br><br><br>"
"错误详情:<br>%@<br>--------------------------<br>%@<br>---------------------<br>%@",
name,reason,[arr componentsJoinedByString:@"<br>"]];
NSURL *url = [NSURL URLWithString:[urlStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
[[UIApplication sharedApplication] openURL:url];
}
bubuko.com,布布扣

然后在

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

里面

函数里面添加

 

bubuko.com,布布扣
NSSetUncaughtExceptionHandler (&UncaughtExceptionHandler);
bubuko.com,布布扣

 


应用崩溃邮件通知,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!