首页 > 其他 > 详细

2016-02-22 版本更新

时间:2016-02-22 17:06:24      阅读:285      评论:0      收藏:0      [点我收藏+]
  • didfinishlauch  appdelegate 中

   

    // 01  gzz022 版本更新 

    [self VersionButton];

    

 

 

 

//02    gzz0222 提示自动更新

-(void)VersionButton{

    NSString  *string=[NSString stringWithContentsOfURL:[NSURL URLWithString:@"https://itunes.apple.com/lookup?id=1079728205"] encoding:NSUTF8StringEncoding error:nil];

    if (string!=nil &&[string length]>0&&[string rangeOfString:@"version"].length==7 ) {

        [self checkUpAppUpdate:string];

    }

   

 

 

}

 

//03   gzz0222

-(void)checkUpAppUpdate:(NSString *)appInfo{

 //获取当前版本

//    NSString *version=[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];//CFBundleShortVersionString

    

    NSString *version=[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];//CFBundleShortVersionString

 

    NSString  *appInfo1=[appInfo substringFromIndex:[appInfo rangeOfString:@"\"version\":"].location+10];

    

    appInfo1=[[appInfo1 substringToIndex:[appInfo1 rangeOfString:@","].location]stringByReplacingOccurrencesOfString:@"\"" withString:@""];

    

    //判断,如果当前版本与发布的版本不相同,则进入更新.如果相等,那么当前版本就是最新版本

    

//    NSString *ver2=@"2.0";

    

    if (![appInfo1 isEqualToString:version]) {

        NSLog(@"%@ 新版本,%@当前版本",appInfo1,version);

        UIAlertView  *alert=[[UIAlertView alloc]initWithTitle:@"" message:[NSString stringWithFormat:@"新版本 %@ 已发布!",appInfo1] delegate:self.class cancelButtonTitle:@"稍后更新" otherButtonTitles:nil, nil];

        alert.delegate=self;

        [alert addButtonWithTitle:@"前往更新"];

        [alert show];

        

        alert.tag=20019;

        

 

    }else{

//       UIAlertView  *alll= [[UIAlertView  alloc]initWithTitle:nil message:@"已是最高版本!" delegate:self.class cancelButtonTitle:@"知道啦!" otherButtonTitles:nil ,nil];

//

//        [alll show];

    

    }

 

 

 

 

}

 

//alertview代理 

- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex{

 

    if (alertView.tag==20019&&buttonIndex==1) {

        NSString  *strUrl=[NSString stringWithFormat:@"https://itunes.apple.com/cn/app/gan-dan-xiang-zhao/id1079728205?mt=8"];

        

        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:strUrl]];

    }

 

 

}

2016-02-22 版本更新

原文:http://www.cnblogs.com/gzz2016/p/5207417.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!