具体实现代码参考源码https://github.com/wolfhous/HSUpdateApp
支持cocoapods:
pod 'HSUpdateApp'用法:
#import 'HSUpdateApp.h'/** 一行代码实现检测app是否为最新版本。appId,bundelId,随便传一个 或者都传nil 即可实现检测。 @param currentVersion 返回当前版本号 @param storeVersion 返回商店版本号 @param openUrl 跳转到商店下载的链接 @param isUpdate 是否需要更新 @return */ [HSUpdateApp hs_updateWithAPPID:nil withBundleId:nil block:^(NSString *currentVersion, NSString *storeVersion, NSString *openUrl, BOOL isUpdate) { }];问题1:这样审核能通过?答1:亲测能通过,没问题的。
问题2:我项目APP ID 在哪里看?答2:itunes connect 》我的APP》APP ID
问题3:假如我的项目还没上线,也没有APP ID 怎么搞?答3:
--直接采用自动检测,appId和bundelId都传nil即可。
--或者去 itunes connect 申请一个APP,就会有对应的APP ID。
--如果你连开发者账号都没有,那就先用demo里面的APP ID 测试吧,上线的时候改过来即可。
1.本地检测项目版本号;
NSDictionary *infoDic=[[NSBundle mainBundle] infoDictionary]; NSString *currentVersion=infoDic[@'CFBundleShortVersionString'];2.联网检测项目在AppStore上的版本号;
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@'?id=%@',appId]]]; NSURLSessionDataTask *task = [session dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) { }]; [task resume];3.比较版本号,可选提供跳转到手机自带的AppStore项目页面供会员下载的地址;
https://itunes.apple.com/us/app/id1104867082?ls=1&mt=8