IOS中使用腾讯Bugly

前言:
最近项目打包分发给客服部门测试,有反馈说在iPhone 7,系统10.1中点击登录之后会有crash的问题,但是我们手上的手机没有问题。又不能把人家的手机拿过来调试,而且可能会有隐藏的crash,平时在测试过程中没有测试出来,又或者是不易复现的bug,于是乎就想到添加错误记录日志~~~

1、只需要QQ号就可以申请账号了
2、新建产品
这里写图片描述
之前我已经新建一个项目了。
3、填写相关信息
这里写图片描述

保存之后就可以获取APP ID、 APP Key

这里写图片描述

4、下载相关的demo,导入相关文件,文档写的很清楚。基本设置页很简单。可根据官方文档设置

这里写图片描述

5、在AppDelegate.m中导入

#import <Bugly/Bugly.h>
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    [Bugly startWithAppId:BUGLY_APP_ID];
//    [self setupBugly];
    return YES;
}

在ViewController.m写一个简单点的点击按钮会crash的代码。

- (void)viewDidLoad {
    [super viewDidLoad];
    //没有实现按钮的点击事件
    UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 100, 30)];
    btn.backgroundColor = [UIColor redColor];
    [btn addTarget:self action:@selector(onClick1) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn];
}

6、在模拟器运行之后,点击按钮,看下Bugly中会有什么展示信息
这里写图片描述

7、在异常报告的奔溃分析中,可以看到crash的原因,点击进去还可以查看详情,能看到相关的解决方案,和一些crash时系统运行了哪些方法,相关的手机信息等。

解决方案:
这里写图片描述

相关的手机信息:
这里写图片描述

堆栈信息:
这里写图片描述

8、也可以自定义bugly的相关设置

- (void)setupBugly {

    BuglyConfig * config = [[BuglyConfig alloc] init];
//    非正常退出事件(SIGKILL)
    config.unexpectedTerminatingDetectionEnable = YES;

    // Open the debug mode to print the sdk log message.
    // Default value is NO, please DISABLE it in your RELEASE version.
    //上传时改为NO
#if DEBUG
    config.debugMode = YES;//开启SDK日志
#endif

    config.reportLogLevel = BuglyLogLevelWarn;

    //卡顿监控
    config.blockMonitorEnable = YES;

    // Set the STUCK THRESHOLD time, when STUCK time > THRESHOLD it will record an event and report data when the app launched next time.
    // Default value is 3.5 second.
    config.blockMonitorTimeout = 1.5;

    //渠道标识
    config.channel = @"Yuna";

    config.delegate = self;
    //进程内还原符号
    config.symbolicateInProcessEnable = YES;

    // NOTE:Required
    // Start the Bugly sdk with APP_ID and your config
    [Bugly startWithAppId:BUGLY_APP_ID
#if DEBUG
        developmentDevice:YES
#endif
                   config:config];

    // Set the customizd tag thats config in your APP registerd on the  bugly.qq.com
    // [Bugly setTag:1799];

    [Bugly setUserIdentifier:[NSString stringWithFormat:@"User: %@", [UIDevice currentDevice].name]];

    //+(NSProcessInfo*)processInfo  //返回当前进程的信息
    //-(NSString*)processName  //返回当前正在执行的进程名称
    [Bugly setUserValue:[NSProcessInfo processInfo].processName forKey:@"Process"];

}

在AppDelegate.m中调用自定义的Bugly配置,不用系统自带的。

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

    //[Bugly startWithAppId:BUGLY_APP_ID];
    [self setupBugly];
    return YES;
}

注意:
我之前测试的时候,在Bugly中看不到crash的日志,主要要确保bugly的初始化要在你crash代码之前。相关常见问题见官方文档

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值