更新版本

-(void)xinban{

    NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];

    NSString *string=@"apikey";

    [request setURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://itunes.apple.com/lookup?id=%@",string]]];

    [request setHTTPMethod:@"GET"];

    NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];

    NSDictionary *jsonData = [NSJSONSerialization JSONObjectWithData:returnData options:0 error:nil];

    

    NSArray *arry=[jsonData objectForKey:@"results"];

    NSString *appstrorebanben=[[arry objectAtIndex:0] objectForKey:@"version"];

    

    self.trackViewUrl1= [[arry objectAtIndex:0] objectForKey:@"trackViewUrl"];//地址trackViewUrl

    NSUserDefaults * setting = [NSUserDefaults standardUserDefaults];

    

    if (![[setting objectForKey:@"appstrore"] isEqualToString:appstrorebanben]) {

        NSDictionary* dict = [[NSBundle mainBundle] infoDictionary];

        NSString  *currntbanben=[dict objectForKey:@"CFBundleVersion"];

        

        if (![currntbanben isEqualToString:appstrorebanben] ) {

            UIAlertView* view = [[UIAlertView alloc] initWithTitle:@"提示" message:@"啊哦,发现有新版本哦,赶快升级吧!" delegate:self cancelButtonTitle:@"先不要啦" otherButtonTitles:@"立即升级", nil];

            [view show];

            [setting setObject:appstrorebanben forKey:@"appstrore"];

        }

    }

}

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

    if (buttonIndex == 1) {

        // 弹出AppStore更新界面

        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@",self.trackViewUrl1]]];

    }

}

 

转载于:https://www.cnblogs.com/106dapeng/p/4683307.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值