版本号设置、检测与更新
来源:互联网 发布:天津稀有金属交易软件 编辑:程序博客网 时间:2024/05/17 08:30
1、版本检测代码:
-(void)checkVersion
{
//当前版本号
NSDictionary *infoDic = [[NSBundlemainBundle] infoDictionary];
NSString *currentVersion = [infoDic objectForKey:@"CFBundleVersion"];
//向AppStore发送同步请求
NSString *URL =@"http://itunes.apple.com/lookup?id=752875885";//你的AppID
NSMutableURLRequest *request = [[NSMutableURLRequestalloc] init];
[requestsetURL:[NSURLURLWithString:URL]];
[requestsetHTTPMethod:@"POST"];
NSHTTPURLResponse *urlResponse = nil;
NSError *error = nil;
NSData *recervedData = [NSURLConnectionsendSynchronousRequest:request returningResponse:&urlResponse error:&error];
//收到返回结果
NSDictionary *dic = [[CJSONDeserializerdeserializer] deserializeAsDictionary:recervedDataerror:&error] ;
NSArray *infoArray = [dic objectForKey:@"results"];
if ([infoArray count]) {
NSDictionary *releaseInfo = [infoArray objectAtIndex:0];
//得到最新appstore上的版本号
NSString *lastVersion = [releaseInfo objectForKey:@"version"];
//如果当前版本与appstore上的版本不一样
if (![lastVersion isEqualToString:currentVersion]) {
UIAlertView *alert = [[UIAlertViewalloc] initWithTitle:@"更新"message:@"有新的版本,是否前往更新?" delegate:self cancelButtonTitle:@"不更新"otherButtonTitles:@"更新",nil];
alert.tag =1000;
[alertshow];
}
}
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (alertView.tag==10000) {
if (buttonIndex==1) {
//跳转到appstore的下载页
NSURL *url = [NSURLURLWithString:@"https://itunes.apple.com/cn/app/yourappname/idxxxxxx?mt=8"];
[[UIApplicationsharedApplication]openURL:url];
}
}
}
2、如何设置当前工程app的版本号
(1)只要简单地设置version和build,其他地方(比如Info.plist)的版本号都会随之改变。可以简单地将version和build设置成一样的。
至于二者的差别可以参考此文:http://blog.csdn.net/kafeidev/article/details/8221273
(2)上面的代码 NSString *currentVersion = [infoDic objectForKey:@"CFBundleVersion"];取出来的build的内容
3、如何知道app在App Store上的ID
(1)在App Store里搜索出你的app,然后右击“拷贝链接”,就可以得到app的下载地址:https://itunes.apple.com/cn/app/ju-duan/idxxxxxx?mt=8,id后面跟的内容就是你的appid。
(2)登录开发者账号,进入“manage your apps”也可找到对应的app的apple id
- 版本号设置、检测与更新
- 判断版本号与更新
- App上架版本号配置的注意事项:CFBundleVersion与CFBundleShortVersionString设置,以及内部检查版本更新
- 检测版本号
- Android版本检测与更新
- Android版本检测与更新
- Android版本检测与更新
- Android版本检测与更新
- 检测硬件平台版本号
- Android检测系统版本号
- javascript 检测浏览器版本号
- 如何在程序内中取到当前版本号,以及检测是否需要更新程序
- android WIFI检测与设置
- android WIFI检测与设置
- android WIFI检测与设置
- maven 更新版本号命令
- 下载更新APP版本号
- Android程序的版本检测与更新
- 公约数 公倍数
- Android 定时任务高度【schedule】与【scheduleAtFixedRate】区别
- logback
- 利用Fragment之间的通信切换标签页
- giflib解码gif图片
- 版本号设置、检测与更新
- 一键搞定Java桌面应用安装部署
- slf4j+logback 多个日志输出配置实例
- xcode5 制作framework
- classname.this 和 this的使用场景
- 自勉
- ARM 指令集版本
- Memcached 简介及C++,Java客户端例程
- 在时间荒芜的长度里 我曾放不下也拿不起的感情