iOS APP版本更新


iOS APP版本检查更新:

下面的都是废话,是不能通过苹果审核的,APP更新现在直接发


布新版本就好,苹果内部会帮我们搞好。比如你之前发布了1.0版


本,现在想发布1.1版本或者更高的,你就直接在苹果开发者中


心:http://developer.apple.com 上传新版本就好。


iOS8之后用户可以设置连接WiFi后有新版本APP可以自动更新,


也可以手动在iPhone上打开APP Store 来更新,千万不能像下面


那样提醒用户有新版本可更新,那样几乎是不能通过苹果审核


的。




iOS8.0之后,苹果规定APP内不能出现“当前版本”之类的字样,以为iOS8.0之后用户可以设置在连接WiFi的情况下自动更新APP,但有些用户可能并不想更新APP,所以要在APP内提醒用户。


检查更新的步骤:


1.可以写个方法来获取APP Store上APP的版本号: (记得要遵循代理

NSURLConnectionDelegate

#pragma mark - 是否有新版本

- (void)isNewVersion{

    //判断 APP version, id 是自己 app 上架时的 Apple id

    NSString *urlStr =@"https://itunes.apple.com/lookup?id=1234567890";

    NSURL *url = [NSURLURLWithString:urlStr];

    NSURLRequest *request = [NSURLRequestrequestWithURL:url];

    [NSURLConnectionconnectionWithRequest:requestdelegate:self];

}


2.在回调方法中进行判断

- (void)connection:(NSURLConnection *)connection didReceiveData:(nonnullNSData *)data{

    NSError *error;

    //序列化

    id jsonObject = [NSJSONSerializationJSONObjectWithData:dataoptions:NSJSONReadingAllowFragmentserror:&error];

    NSDictionary *appInfo = (NSDictionary *)jsonObject;

    MCLog(@"%@",appInfo);

    

    NSArray *infoContent = [appInfoobjectForKey:@"results"];

    NSString *appVersion = [[infoContentobjectAtIndex:0]objectForKey:@"version"];

    MCLog(@"APP version is %@",appVersion);

  

//地址

    NSString *trackViewUrlStr = [[infoContentobjectAtIndex:0]objectForKey:@"trackViewUrl"];

    //当前版本

    NSString *currentVersion = [NSBundlemainBundle].infoDictionary[@"CFBundleShortVersionString"];

    MCLog(@"current version is %@",currentVersion);


    if (![appVersionisEqualToString:currentVersion]) {

        UIAlertController *alertController = [UIAlertControlleralertControllerWithTitle:@"检查更新"message:[NSStringstringWithFormat:@"发现新版本(%@),是否升级?",appVersion]preferredStyle:UIAlertControllerStyleAlert];

        

        UIAlertAction *cancalAction = [UIAlertActionactionWithTitle:@"取消"style:UIAlertActionStyleDefaulthandler:^(UIAlertAction *_Nonnull action) {

            

        }];

        

        UIAlertAction *confirmAction = [UIAlertActionactionWithTitle:@"升级"style:UIAlertActionStyleDefaulthandler:^(UIAlertAction *_Nonnull action) {

            //点击升级,跳到APP store进行更新

            [[UIApplicationsharedApplication]openURL:[NSURLURLWithString:trackViewUrlStr]];

        }];

        

        [alertController addAction:cancalAction];

        [alertController addAction:confirmAction];

        

        [self.window.rootViewControllerpresentViewController:alertControlleranimated:YEScompletion:nil];

    }

}





  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值