博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
(转)iOS如何取得APP的版本信息跟服务器对比进行升级提示?
阅读量:7022 次
发布时间:2019-06-28

本文共 1609 字,大约阅读时间需要 5 分钟。

关键是自动取版本信息:

[NSString stringWithFormat:@"Version %@",[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"]];[NSString stringWithFormat:@"Build %@",[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]];

  

然后对比服务器上的版本,这个你得自己通过WEB提供,示例中就先写出来:

#define APP_DownloadURL @"http://itunes.apple.com/app/id483504146?mt=8" //换成你自己的APP地址- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {    if (buttonIndex != [alertView cancelButtonIndex])     {       NSURL *url = [NSURL URLWithString:APP_DownloadURL];       [[UIApplication sharedApplication] openURL:url];    }}-(void)alertUpdate:(NSString *)strContent{    if (!isAlertUpdateShowed) {        isAlertUpdateShowed=YES;        UIAlertView *av = [[[UIAlertView alloc] initWithTitle:@"升级提示"                                                      message:strContent                                                     delegate:self       //委托给Self,才会执行上面的调用                                            cancelButtonTitle:@"以后再说"                                            otherButtonTitles:@"马上更新",nil] autorelease];        [av show];    }}-(void)checkUpdate{    NSString* sLastVersion=@"1.1"; //取最新的版本自己去实现    NSString* sLastVersionInfo=@"Test Update Check!"; //取最新的版本介绍自己去实现    if (![sLastVersion isEqualToString:[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"]])    {         [self alertUpdate:sLastVersionInfo];    }}

  还需要实现一些延时再提醒的处理。

 

转载自:http://www.cnblogs.com/gpwzw/archive/2012/03/31/2426698.html

转载于:https://www.cnblogs.com/greywolf/p/3262335.html

你可能感兴趣的文章
javascript之this指向
查看>>
FTP实时更新上传脚本
查看>>
awk中多个分隔符^识别办法
查看>>
Centos7 初始化MySQL5.7数据库
查看>>
从零开始的linux 第十八章
查看>>
c#获取逻辑硬盘信息
查看>>
vSphere虚拟化之vClient安装虚拟机
查看>>
23种设计模式介绍(二)---- 结构型模式
查看>>
IOT物联网观察之商业本质是价值交换,物量经济交换逻辑是什么?
查看>>
MySQL8.0 新特性:Partial Update of LOB Column
查看>>
计算机网络数据链路层
查看>>
Python库的使用
查看>>
云上自动化:全球云上自动化编排系统比拼
查看>>
解读AI行业发展趋势
查看>>
嵌入式开发培训都要学什么?零基础参加嵌入式学习培训能学会吗
查看>>
flume的初体验
查看>>
hbase的基本操作
查看>>
DevOps工程师到底做些什么?
查看>>
解析RDD在Spark中的地位
查看>>
高质量SEO文章编辑规范技巧之:格式
查看>>