9980feb5e497484699ac6fd8c039a274.gif

项目介绍:

具体实现代码参考源码https://github.com/wolfhous/HSUpdateApp

文件小巧,轻便:

5e47c6f330564ca71ae23d49d431bb2c.png

支持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:@"http://itunes.apple.com/cn/lookup?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

下载该GitHub源码请点我

Logo

瓜分20万奖金 获得内推名额 丰厚实物奖励 易参与易上手

更多推荐