//检查更新页面

- (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];
}

IOS中打开应用实现检查更新的功能的更多相关文章

  1. iOS开发中打开本地应用、打开appStore应用、给app评分功能实现

    app开发中,通常会有邀请用户给app打分的功能.而在iOS中,正式应用都是通过appStore 下载的,因此给app 打分也只能在 appStore中.因此,需要从应用跳转到appStore.方法是 ...

  2. iOS评分功能、APP中打开其他应用程序

    1.评分功能 iOS中评分支持功能开发非常简单. NSString *str = [NSString stringWithFormat: @"itms-apps://itunes.apple ...

  3. IOS中调用系统的电话、短信、邮件、浏览功能

    iOS开发系列--通讯录.蓝牙.内购.GameCenter.iCloud.Passbook系统服务开发汇总 2015-01-13 09:16 by KenshinCui, 26990 阅读, 35 评 ...

  4. 【IOS】在SDK中打开其他接入应用的解决方案

      在SDK中打开其他接入应用的解决方案 一直以来,在iOS的开发中,在程序中打开另外一个应用是不允许.后来有正义之士用class-dump在私有API中找到了这样的功能.那就是使用UIApplica ...

  5. 在IOS应用中打开另外一个应用的解决方案

    最近要在IOS中实现一个应用启动另外一个应用的功能,搜了一些资料,使用UIApplication的openURL:的方法就能实现,现在整理和大家分享一下! 注册自定义URL协议 首先被启动的应用需要向 ...

  6. iOS中打电话、打开网址、发邮件、发短信等

    常用小功能 小功能简介 iOS中的很多小功能都是非常简单的,几行代码就搞定了,比如打电话.打开网址.发邮件.发短信等 打电话-方法1 最简单最直接的方式:直接跳到拨号界面 NSURL *url = [ ...

  7. 如何在ios中集成微信登录功能

    在ios中集成微信的登录功能有两种方法 1 用微信原生的api来做,这样做的好处就是轻量级,程序负重小,在Build Settings 中这样设置 然后设置 友盟的设置同上,但是要注意,加入你需要的所 ...

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

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

  9. 利用openURL,在IOS应用中打开另外一个应用

    在IOS中,实现一个应用启动另外一个应用,使用UIApplication的openURL:方法就可实现,这里以test跳到test02为例.(需要先创建这两个工程) 注册自定义URL协议(在test中 ...

随机推荐

  1. hbase基本概念和hbase shell常用命令用法

    1. 简介 HBase是一个分布式的.面向列的开源数据库,源于google的一篇论文<bigtable:一个结构化数据的分布式存储系统>.HBase是Google Bigtable的开源实 ...

  2. SharePoint 2010 BCS - 简单实例(二)外部列表创建

    博客地址 http://blog.csdn.net/foxdave 接上篇 由于图片稍多篇幅过长影响阅读,所以分段来写. 添加完数据源之后,我们需要为我们要放到SharePoint上的数据表定义操作, ...

  3. Windows Azure上搭建SSTP VPN

    一.服务器设置 首先,从0开始,你需要创建一个新的VM.我选择Windows Server 2012 R2,所有步骤和创建普通VM都一样,但最后在防火墙设置里一定要打开TCP 443端口: 创建完成后 ...

  4. Unknown type name “CGFloat

    一.编绎显示Unknown type name “CGFloat”  错误解决方法 将Compile Sources As 改为 Objective-C++ 二.如果是extern const引起的. ...

  5. Security Checklist (路由器安全checklist)

    Security Checklist Website by     Michael Horowitz  Home | Introduction | Router Bugs | Security Che ...

  6. (spring-第11回【IoC基础篇】)BeanWrapper--实例化Bean的第四大利器

    重复是理解和记忆的最好方法.在讲实例化Bean的每个步骤之前,我都会先复习一下Bean实例化的整个过程: 结合图片我们回顾一下具体的过程: ResourceLoader加载配置信息, 由BeanDef ...

  7. Map写入的顺序 输出地顺序ZT

    偶然间 发现hashmap遍历的结果不是放入的顺序 为了项目某个功能更人性话 思考了半天还是不知道如何下手 因为有种种条件限制 后来 无意中发现 java.util.LinkedHashMap< ...

  8. 用python做些有意思的事——分析QQ聊天记录——私人订制

    之前,写了这篇文章,用python提取全部群成员的发言时间,并简单做了下分析.先补充一下,针对特定单个群成员(这里以  小小白   为例)消息记录的获取. 代码比较简单,主要是正则表达式的书写.(附: ...

  9. 如何去除内联元素(inline-block元素)之间的间距(转载)

    如何去除内联元素(inline-block元素)之间的间距   前几天写一个专题页 div{width:900px;}div a{ display:inline-block; width:300px; ...

  10. HDOJ-三部曲-1002-Etaoin Shrdlu

    ContestsProblemsRanklistStatusStatistics Etaoin Shrdlu Time Limit : 2000/1000ms (Java/Other)   Memor ...