码迷,mamicode.com
首页 > 移动开发 > 详细

iOS 版本更新

时间:2014-10-17 15:47:30      阅读:173      评论:0      收藏:0      [点我收藏+]

标签:http   io   os   ar   for   sp   文件   on   cti   

获取当前版本、比较线上版本、然后决定是否更新

当前版本:
    //////获取 info.plist文件内容
    NSDictionary *infoDic = [[NSBundle mainBundle] infoDictionary];  
    ////获取general 里的 build
    NSString *appVersion = [infoDic objectForKey:@"CFBundleVersion"];
    ////获取general 里的 version
    NSString *currentVersion = [infoDic objectForKey:@"CFBundleShortVersionString"];
    
线上版本:
    1、POST请求方式:http://itunes.apple.com/search?term=你的应用程序名称&entity=software
    2、http://itunes.apple.com/lookup?id=“tunes connect里的 Apple ID”
    
    用2获取:
    NSDictionary *dicVersion = [NSJSONSerialization JSONObjectWithData:dataes options:0 error:nil];
    NSMutableArray *arrayVersion = [NSMutableArray arrayWithArray:[dicVersion objectForKey:@"results"]];    
    NSDictionary *resultsVersion = [arrayVersion objectAtIndex:0];
    NSString *lastVersion = [resultsVersion objectForKey:@"version"];
    NSString *trackViewUrl = [resultsVersion objectForKey:@"trackViewUrl"];
    
决定是否更新:
    if ([arrayVersion count]) {
        if (![lastVersion isEqualToString:currentVersion]) {
            ////更新
        }else{
            ////不更新
        }
     }
     
////官方文档:
www.apple.com/itunes/affiliates/resources/documentation/itunes-store-web-service-search-api.htm

////////更新提醒:
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    if (alertView.tag==888) {
        if (buttonIndex==0) {
            NSURL *url = [NSURL URLWithString:trackViewUrl];
            [[UIApplication sharedApplication]openURL:url];
        }
    }
}




iOS 版本更新

标签:http   io   os   ar   for   sp   文件   on   cti   

原文地址:http://my.oschina.net/u/1451688/blog/333201

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!