//检查更新页面

- (void)Renew{
    
    NSDictionary *infoDic = [[NSBundle mainBundle]infoDictionary];
    
    NSString *version = [infoDic valueForKey:@"CFBundleShortVersionString"];
    
    NSString *ipstr = [NSObject  deviceIPAdress];
    
    NSString *paramIp = ipstr;
    
    NSTimeInterval time = [[NSDate  date]timeIntervalSince1970];
    
    long i = time;
    
    NSString *paramTime = [NSString stringWithFormat:@"%ld",i];
    
    NSString *signstr = [NSString  stringWithFormat:@"%@%@%@%@",paramTime,paramIp,@"phone_ios",@"d556bd3337cd909b49eb5e33f46ad65c"];
    
    NSString *md5str =  [signstr MD5Hash];
    
    NSString *mdstr = [md5str   lowercaseString];
    
    NSString *sign = mdstr;
    
    NSString *key = @"phone_ios";
    
    NSDictionary *param = @{
                            @"type" : @2,
                            
                            @"version" : version
                            
                            };
    
    NSDictionary *dict = @{
                           
                           @"paramTime" : paramTime,
                           
                           @"paramIp" : paramIp,
                           
                           @"sign":sign,
                           
                           @"key" : key,
                           
                           @"param":param
                           
                           };
    
    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    
    manager.requestSerializer = [AFJSONRequestSerializer serializer];
    
    manager.responseSerializer =  [AFJSONResponseSerializer  serializer];
    
    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"application/json"];
    
    [manager POST:RenewUrl parameters:dict success:^(AFHTTPRequestOperation *operation, id responseObject) {
        
        NSDictionary *resultDic = responseObject[@"result"];
        
        _upgradeUrl = resultDic[@"upgradeUrl"];
        
          _force = resultDic[@"isForce"];
        NSLog(@"_force--------%@",_force);
     
        NSLog(@"%@",resultDic);
        
        if ([resultDic[@"isForce"]compare:@0] !=NSOrderedSame) {
            
        UIAlertView *isForceView = [[UIAlertView alloc]initWithTitle:@"特别提示" message:@"发现新版本" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"下载", nil];
            
            
            [isForceView show];
            
        }else if ([resultDic[@"version"]compare:version] != NSOrderedSame) {
            
            UIAlertView *resultView = [[UIAlertView alloc]initWithTitle:@"提示" message:@"发现新版本" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"下载", nil];
            
            [resultView show];
            
        }else{
            
            return ;
        }
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
        UIAlertView *errorView = [[UIAlertView alloc]initWithTitle:@"提示" message:@"网络有问题" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
        
        [errorView show];
        
        NSLog(@"%@",error);
    }];
}

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
    
    if ([_force compare:@1 ]!=NSOrderedSame) {
        
        if (buttonIndex==1) {
            
            [self  startDownLoad];
            
//            [[UIApplication  sharedApplication]openURL:[NSURL URLWithString:_upgradeUrl]];
        }
        
        }else if ([_force  compare:@0] !=NSOrderedSame){
        
        if ( buttonIndex == 1) {
            
//            [[UIApplication  sharedApplication]openURL:[NSURL URLWithString:_upgradeUrl]];
            
            [self  startDownLoad];
            
        }else if (buttonIndex == 0){
            
            exit(0);
            
        }
    }
    
}

- (void) startDownLoad{

NSURL *url = [NSURL URLWithString:_upgradeUrl];
    
//    NSLog(@"url-------%@",url);
    
    NSURLRequest *request = [NSURLRequest  requestWithURL:url];
    
    NSURLConnection *connect = [NSURLConnection  connectionWithRequest:request delegate:self];
    
    [connect  start];
}

转载于:https://www.cnblogs.com/er-dai-ma-nong/p/4876047.html

IOS中打开应用实现检查更新的功能相关推荐

  1. ios怎么打开c语言文件夹,iOS中打开的文件如何用其他应用打开选择自己的app

    效果如图: 用其他应用打开 选择某一应用 1.设置 Info.plist CFBundleDocumentTypes CFBundleTypeIconFiles 96.png 96@2x.png CF ...

  2. ios中wallproxy使用教程

    1.添加Cydia源 cydia.myrepospace.com/iwyg ,搜索安装 python, wallproxy-local 2.在Safari 中打开 http://127.0.0.1:8 ...

  3. 还可以这么玩:盘点iOS 11中Siri的12项新功能

    本文讲的是 还可以这么玩:盘点iOS 11中Siri的12项新功能, iOS 11的首次亮相带来了一些变化,其中包括增强现实游戏和更好的iMessage体验,但或许操作系统在任何方面的改变都不如Sir ...

  4. XamarinSQLite教程Xamarin.iOS项目中打开数据库文件

    XamarinSQLite教程Xamarin.iOS项目中打开数据库文件 以下是打开MyDocuments.db数据库的具体操作步骤: (1)将Mac电脑上的MyDocuments.db数据库移动到W ...

  5. 学习 launch-editor 源码整体架构,探究 vue-devtools「在编辑器中打开组件」功能实现原理...

    1. 前言 你好,我是若川[1],微信搜索「若川视野」关注我,专注前端技术分享,一个愿景是帮助5年内前端开阔视野走向前列的公众号.欢迎加我微信ruochuan12,长期交流学习. 这是学习源码整体架构 ...

  6. 浏览器中打开IOS应用并传参

    原创文章,转载请注明 开发中遇到这么一个问题,就是动态地指定联接服务器地址,或其它数据.如果是其它数据还好说一些,可以通过在服务器上获得的方式来弄.但如果服务器地址都需要动态指定的话.那就得另想办法了 ...

  7. outlook单独下载_在单独的Windows中打开不同的Outlook功能以提高生产率

    outlook单独下载 If you work in Outlook for much of the workday, you may find it annoying having to navig ...

  8. 打开 Ubuntu 18 中 Vim 的系统剪切板功能

    打开 Ubuntu 18 中 Vim 的系统剪切板功能 文章目录 打开 Ubuntu 18 中 Vim 的系统剪切板功能 1. 查看 Vim 是否支持系统剪切板 2. 开启系统剪切板功能 3. 系统剪 ...

  9. 判断ios/android设备;判断页面是否在微信中打开

    简单版,vue判断是否在微信中: // 微信打开methods:{weChatOpen() {return navigator.userAgent.toLowerCase().indexOf('mic ...

最新文章

  1. CentOS 7.7 安装cmake3
  2. libreadline.so.6: undefined symbol
  3. UA SIE545 优化理论基础 用Farkas定理证明Farkas类的结论
  4. 周学习进度----03
  5. Java8-本地缓存
  6. 160 - 3 Afkayas.2
  7. 详解 | 求你别用效率低下的I/O了,要不试试这种I/O
  8. 单片机电源自动切换电路,mos双电源自动切换电路,电池与usb供电自动切换电路
  9. keil p0 0c语言不了,Keil C51对C语言的关键词扩展之十三: sfr
  10. Python爬取百度热榜前十条数据
  11. ArcGIS连接pg数据库
  12. mysql命令执行cmd命令_mysql cmd常用命令
  13. 黄金分割法求解局部最小值——python实现
  14. 我的专业作文300字计算机,以我的专业为题的作文(以我写一篇作文300字)
  15. 从自己挖的坑里爬出来
  16. DPABI(用于脑成像的数据处理和分析的工具箱)的下载和安装步骤
  17. postgresql 索引之 gin、btree_gin
  18. 使用python编写的落网电台下载工具
  19. Word~Word修改行间距磅值
  20. 计算机维修员周记300字,计算机实习周记300字.doc

热门文章

  1. html5调用系统声音1s响一次_HTML5声音录制/播放功能的实现代码
  2. 74ls390设计任意进制计数器_异步FIFO:设计原理及Verliog源码
  3. jenkins获取远程服务器文件,Jenkins用SSH传输文件到远程服务器
  4. mysql定义条件和处理_MySQL定义条件和处理程序
  5. java事件处理模型_从零开始理解JAVA事件处理机制(3)
  6. jsp 插入mysql乱码_JSP MySQL插入数据时出现中文乱码问题的解决方法
  7. kafka 异步发送阻塞_Kafka学习一
  8. 烟台大学计算机专业录取分数线,2017烟台大学录取分数线排行榜
  9. 2021年广东省高考英语听说成绩查询,广东2021年高考准考证今起自行打印 成绩及分数线6月24日左右公布...
  10. asp.net webform 复制窗体代码_逆向分析流氓软件自我复制以及防御思路