zoukankan      html  css  js  c++  java
  • JJException防崩溃+Bugly上报异常

    1.cocoapods安装以下类库

    pod 'JJException'

     遵循协议 JJExceptionHandle

     

    pod 'Bugly', '~> 2.5.71'

    2.AppDelegate 导入头文件

    #import <JJException.h>
    #import <Bugly/Bugly.h>

    3. didFinishLaunchingWithOptions 正式环境开启防崩溃

    配置

        #ifdef RELEASE
        // 开启防崩溃
        [JJException configExceptionCategory:JJExceptionGuardAll];
        [JJException startGuardException];
        [JJException registerExceptionHandle:self];
        #endif

    配置bugly

        //配置bugly(模拟器和debug 不上传bug)
    #ifndef DEBUG
        if (![[UIDevice currentDevice] isSimulator]) {
            [self configBugly];
        }
    #endif
    - (void)setBuglyUserInfo {
        [Bugly setUserIdentifier:@"传用户id"];
        [Bugly setUserValue:@"传用户手机号" forKey:@"UserMobile"];
        [Bugly setUserValue:@"传用户名" forKey:@"UserName"];
        [Bugly setUserValue:@"传正式环境还是测试环境" forKey:@"Environment"];
    }
    
    - (void)configBugly {
        [self setBuglyUserInfo];
        //用户登录成功后 需要重新上传userid 需要发送通知 这边才能更新 注意注意
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(setBuglyUserInfo) name:kLoginSuccessNotification object:nil];
        //初始化 Bugly 异常上报
        BuglyConfig *config = [[BuglyConfig alloc] init];
        config.debugMode = NO;
        config.reportLogLevel = BuglyLogLevelVerbose;
        [Bugly startWithAppId:@"传bugly申请的应用appid"
    #ifndef RELEASE
            developmentDevice:YES
    #endif
                       config:config];
    }

    在代理方法里上报异常

    //JJException 防崩溃代理
    - (void)handleCrashException:(nonnull NSString *)exceptionMessage extraInfo:(nullable NSDictionary *)info {
        NSLog(@"App Crash------------ %@", [NSException exceptionWithName:@"AvoidCrash" reason:exceptionMessage userInfo:info]);
        
        [Bugly reportException:[NSException exceptionWithName:@"AvoidCrash" reason:exceptionMessage userInfo:info]];
    }
    在北京的灯中,有一盏是我家的。这个梦何时可以实现?哪怕微微亮。北京就像魔鬼训练营,有能力的留,没能力的走……
  • 相关阅读:
    一步一步学习IdentityServer4 (4) 处理特殊需求之-登录等待页面
    php 打包下载
    nginx https反向代理tomcat
    the "ssl" parameter requires ngx_http_ssl_module in /usr/local/nginx/conf/nginx.conf
    layui配置
    vue 学习一
    MyCAT+MySQL 搭建高可用企业级数据库集群——第3章 MyCat核心配置讲解
    第一模块·开发基础-第3章 作业讲解
    《扭转人生的40个哲学提问》 徐帆 著
    零基础学 JavaScript 全彩版 明日科技 编著
  • 原文地址:https://www.cnblogs.com/huangzs/p/15213253.html
Copyright © 2011-2022 走看看