IOS检测版本更新(***为app id)

iOS应用版本检查与更新
本文介绍了一种iOS应用检查版本更新的方法,并实现了版本提示与跳转至App Store的功能。通过解析从iTunes获取的数据来判断当前应用是否为最新版本。
/////////////////////测试版本更新
-(void)GetUpdate
{
    NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary];
    NSString *nowVersion = [infoDict objectForKey:@"CFBundleVersion"];
    
    NSURL *url = [NSURL URLWithString:@"http://itunes.apple.com/lookup?id=6224939"];//
    NSString * file =  [NSString stringWithContentsOfURL:url];
    file= [file stringByReplacingOccurrencesOfString:@"\n" withString:@""];
    if(file !=nil)
    {
        int count= [[g_json GetValueWithJsonKey:file key:@"resultCount"]intValue];
        if(count>0)
        {
            file = [file substringWithRange:NSMakeRange(31, file.length-33)];
            NSString *newVersion = [g_json GetValueWithJsonKey:file key:@"version"];
            if([nowVersion isEqualToString:newVersion]==NO)
            {
                [self performSelectorOnMainThread:@selector(AlertNewVersion:) withObject:nil waitUntilDone:NO];
                
                
            }
        }
        
    }
    
}

-(void)AlertNewVersion:(id)sender
{
    UIAlertView *alertNewVer = [[UIAlertView alloc]initWithTitle:nil message:@"版本有更新" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"更新", nil];
    [alertNewVer show];
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    if(buttonIndex==1)
    {
        NSURL *url = [NSURL URLWithString:@"https://itunes.apple.com/us/app/xg-ke-hui/id622493449?ls=1&mt=8"];
        [[UIApplication sharedApplication]openURL:url];
    }
}

////////////////////////////////

转载于:https://www.cnblogs.com/zzzili/archive/2013/01/28/6662635.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值