惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

aimingoo的专栏
aimingoo的专栏
有赞技术团队
有赞技术团队
博客园 - Franky
J
Java Code Geeks
美团技术团队
WordPress大学
WordPress大学
V
Visual Studio Blog
量子位
Hugging Face - Blog
Hugging Face - Blog
V
V2EX
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
人人都是产品经理
人人都是产品经理
博客园 - 三生石上(FineUI控件)
博客园 - 司徒正美
爱范儿
爱范儿
宝玉的分享
宝玉的分享
博客园 - 【当耐特】
D
DataBreaches.Net
云风的 BLOG
云风的 BLOG
The Cloudflare Blog
MyScale Blog
MyScale Blog
The GitHub Blog
The GitHub Blog
博客园_首页
U
Unit 42
O
OpenAI News
T
The Blog of Author Tim Ferriss
Microsoft Security Blog
Microsoft Security Blog
H
Help Net Security
S
SegmentFault 最新的问题
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
T
Threat Research - Cisco Blogs
月光博客
月光博客
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Cisco Talos Blog
Cisco Talos Blog
T
Tailwind CSS Blog
A
About on SuperTechFans
AWS News Blog
AWS News Blog
Recorded Future
Recorded Future
A
Arctic Wolf
H
Hackread – Cybersecurity News, Data Breaches, AI and More
T
Tenable Blog
大猫的无限游戏
大猫的无限游戏
I
Intezer
K
Kaspersky official blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
The Register - Security
The Register - Security
G
Google Developers Blog
雷峰网
雷峰网
V
Vulnerabilities – Threatpost

博客园 - 恋上你的笑

NSDateFormatter format strings math.h里的数学计算公式介绍<转> SQLite函数大全 GCD介绍(转) Objective-C Blocks研究(转) CGContext<转CC> Iphone开发-NSdata 与 NSString,Byte数组,UIImage 的相互转换<转> Mac下的svn命令使用方法<转> 解决:XCODE 4.2 无法连接SVN,提示:Unable to load revisions 常用路径操作方法 ios开发小知识3 xcode中使用ARC问题 ios常用网络编程要点 NSString用法总结 Quartz 2D编程 ios开发小知识2(转自cc) object-c开发中混合使用或不使用ARC(转) 3DES+Base64 加密解密的方法(转) In App Purchases 入门(转)
app在程序中设置版本自动更新的步骤
恋上你的笑 · 2012-07-02 · via 博客园 - 恋上你的笑

1.通过post方式发送请求:http://itunes.apple.com/lookup?id=你的应用程序的ID

2.从获得的 response 数据中解析需要的数据。因为从 appstore 查询得到的信息是 JSON 格式的,所以
需要经过解析。解析之后得到的原始数据就是如下这个样子的

{  
    resultCount = 1;  
    results =     (  
                {  
            artistId = 开发者 ID;  
            artistName = 开发者名称;
            price = 0;
            isGameCenterEnabled = 0;  
            kind = software;  
            languageCodesISO2A =             (  
                EN  
            );
            trackCensoredName = 审(我们的)查名称;  
            trackContentRating = 评级;  
            trackId = 应用程序 ID;
            trackName = 应用程序名称";  
            trackViewUrl = 应用程序介绍网址;  
            userRatingCount = 用户评级;  
            userRatingCountForCurrentVersion = 1;  
            version = 版本号;  
            wrapperType = software;
      }  
    );  
}

#pragma direct open itunes  此部分代码为实现在app直接调用手机的app store应用并导向本app的链
接页面
-(void)openReferralURL:(NSURL *)referralURL{
    NSURLConnection *con = [[NSURLConnection alloc] initWithRequest:[NSURLRequest  
requestWithURL:referralURL] delegate:self startImmediately:YES];
    [con release];
}
-(NSURLRequest *)connection:(NSURLConnection *)connection willSendRequest:(NSURLRequest *)
request redirectResponse:(NSURLResponse *)response{
    self.iTunesURL = [response URL];
    if ([self.iTunesURL.host hasSuffix:@"itunes.apple.com"]) {
        [connection cancel];
        [self connectionDidFinishLoading:connection];
        return nil;
    }else{
        return request;
    }
}
-(void)connectionDidFinishLoading:(NSURLConnection *)connection{
    [[UIApplication sharedApplication] openURL:self.iTunesURL];
}
#end pragram

-(void)afterItuensConnect:(ASIHTTPRequest *)request//请求完成之后调用的函数
{
    NSString *responseStr = [request responseString];//NSLog(@"%@",responseStr);
    NSDictionary *dic = [responseStr JSONValue];
    NSArray *infoArrays = [dic objectForKey:@"results"];
    NSDictionary *releaseInfo = [infoArrays objectAtIndex:0];
    self.itunes_url = [releaseInfo objectForKey:@"trackViewUrl"];
    NSString *version =[releaseInfo objectForKey:@"version"];//最新版本号,itunes上的为最新
的,而不是程序中的
    NSString *lastVersion =[[NSBundle mainBundle]  
objectForInfoDictionaryKey:@"CFBundleVersion"];//本次版本的版本号,在info.plist文件中设置的   
Bundle Version字段
   
    NSString *l_Path = [[lastVersion componentsSeparatedByString:@"."] objectAtIndex:0];
    NSString *p_Path = [[version componentsSeparatedByString:@"."] objectAtIndex:0];
    BOOL result = [l_Path compare:p_Path] == NSOrderedAscending;
   
    BOOL error_result = [p_Path compare:l_Path] == NSOrderedAscending;
    if (error_result) {
        return;
    }
   
    if ([lastVersion isEqualToString:version]) {
        //版本号相同,无任何操作
    }
    else if (result) {//第一个版本号大,强制更新
        update_tab = @"closeApp";
        UIAlertView *alerView = [[UIAlertView alloc]initWithTitle:@"" message:
[self.appIdAndAlertStr objectForKey:@"MandatoryUpdateStr"] delegate:self  
cancelButtonTitle:@"No" otherButtonTitles:@"Yes", nil];
       
        [alerView show];
        [alerView release];
    }else{//非强制性更新
        update_tab = @"";
        UIAlertView *alerView = [[UIAlertView alloc]initWithTitle:@"" message:
[self.appIdAndAlertStr objectForKey:@"SelectiveUpdateStr"] delegate:self  
cancelButtonTitle:@"No" otherButtonTitles:@"Yes", nil];
        [alerView show];
        [alerView release];
    }
 
}

-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
    if ([alert_lab isEqualToString:@"no_network"]) {
        exit(0);
    }
    if(buttonIndex>0){//click "yes" in update app alert
        // turn to update app web page..
        NSURL *url = [NSURL URLWithString: self.itunes_url];
        [self openReferralURL:url];
      
    }else{//click "no"
        if ([update_tab isEqualToString:@"closeApp"]) {
            exit(0);
        }