Umeng日志记录和版本升级

本文详细介绍了如何在iOS应用中集成并使用友盟SDK,包括设置应用版本、开启异常捕获、调试日志、自动更新检查等功能。通过示例代码展示了如何在不同场景下灵活运用友盟SDK,提升应用的用户体验。
-(void)OpenUMeng //打开友盟
{
    [MobClick setCrashReportEnabled:YES]; // 如果不需要捕捉异常,注释掉此行
//    [MobClick setLogEnabled:YES];  // 打开友盟sdk调试,注意Release发布时需要注释掉此行,减少io消耗
    [MobClick setAppVersion:XcodeAppVersion]; //参数为NSString * 类型,自定义app版本信息,如果不设置,默认从CFBundleVersion里取
    //
    [MobClick startWithAppkey:UMENG_APPKEY reportPolicy:(ReportPolicy) REALTIME channelId:@"YunFeng"];
    //   reportPolicy为枚举类型,可以为 REALTIME, BATCH,SENDDAILY,SENDWIFIONLY几种
    //   channelId 为NSString * 类型,channelId 为nil或@""时,默认会被被当作@"App Store"渠道
    
//    [MobClick checkUpdate];   //自动更新检查, 如果需要自定义更新请使用下面的方法,需要接收一个(NSDictionary *)appInfo的参数
    [MobClick checkUpdateWithDelegate:self selector:@selector(updateMethod:)];
    
    [MobClick updateOnlineConfig];  //在线参数配置

}



- (void)updateMethod:(NSDictionary *)appInfo {
    NSLog(@"update info %@",appInfo);
    if([[appInfo objectForKey:@"update"] isEqualToString:@"YES"]==YES)
    {
        NSString *newVersion = [[NSString alloc]initWithString:[appInfo objectForKey:@"version"]];
        self.newVersionPath = [[NSString alloc]initWithString:[appInfo objectForKey:@"path"]];
        UIAlertView *alert = [[UIAlertView alloc]initWithTitle:[NSString stringWithFormat:@"有新版本V%@",newVersion] message:[NSString stringWithString:[appInfo objectForKey:@"update_log"]] delegate:self cancelButtonTitle:@"下次再说" otherButtonTitles:@"更新", nil];
        [alert show];
                              
    }
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    if(buttonIndex==1)
    {
        NSURL *url = [NSURL URLWithString:self.newVersionPath];  [[UIApplication sharedApplication]openURL:url];
    }
}


转载于:https://www.cnblogs.com/zzzili/p/6685299.html

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值