ios设备版本更新
来源:互联网 发布:温庭筠入骨相思知不知 编辑:程序博客网 时间:2024/05/22 09:51
1. 应用程序已经放在appstore时更新比较简单,就是比较版本号,当发现版本高于当前版本时,就访问appstore应用程序所在位置,让用户决定是否更新。
使用xml文件保存版本信息,updateInfo_ios.xml内容如下
[cpp] view plaincopyprint?
- <?xml version="1.0" encoding="UTF-8"?>
- <updateInfo>
- <version>1.0.1</version>
- <description>软件升级!!!</description>
- <path>itms-apps://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=524298520</path>
- </updateInfo>
其中,version是新的版本号,path是应用程序在appstore的地址
使用TBXML读取从服务端请求来的xml文件内容,这里请求回来的是string类型
[cpp] view plaincopyprint?
- TBXML *xml = [[TBXML alloc] initWithXMLString:jsonString error:nil];
- TBXMLElement *update = xml.rootXMLElement;
- if (update == nil) {
- [Tool ToastNotification:@"获取版本信息错误" andView:self.view andLoading:NO andIsBottom:NO];
- return;
- }
- TBXMLElement *versionXML = [TBXML childElementNamed:@"version" parentElement:update];
- if (versionXML == nil) {
- [Tool ToastNotification:@"获取版本信息错误" andView:self.view andLoading:NO andIsBottom:NO];
- return;
- }
- TBXMLElement *pathXML = [TBXML childElementNamed:@"path" parentElement:update];
- if (versionXML == nil) {
- [Tool ToastNotification:@"获取版本信息错误" andView:self.view andLoading:NO andIsBottom:NO];
- return;
- }
- versionPath = [TBXML textForElement:pathXML];
- NSString *version = [TBXML textForElement:versionXML];
- if ([MenuViewController getVersionNumber:version]>[MenuViewController getVersionNumber:AppVersion]) {
- UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"温馨提示" message:@"天翼视讯iPhone推流客户端有新版了\n您需要下载吗?" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确认", nil];
- [alert show];
- }
- else
- {
- UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"温馨提示" message:@"您当前已经是最新版本" delegate:self cancelButtonTitle:@"返回" otherButtonTitles:nil, nil];
- [alert show];
- }
#define AppVersion @"1.0.0"
这个是当前版本,后面有新版本程序的时候,修改summary的版本时不要忘记修改这里,不然就要一直提示有更新了当版本号大于当前版本,就提示更新,用户点击确认后,跳转
[cpp] view plaincopyprint?
- - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
- {
- if (buttonIndex == 1) {
- //下载
- [[UIApplication sharedApplication] openURL:[NSURL URLWithString:versionPath]];
- }
- }
2. 现在,开发阶段,应用程序没有放在appstore,想安装新的app
我们需要将工程生成ipa文件和关于ipa文件信息的plist文件,然后程序里访问plist文件。
同样,使用xml文件保存版本信息
比如文件updateInfo_ios.xml内容如下:
[cpp] view plaincopyprint?
- <?xml version="1.0" encoding="UTF-8"?>
- <updateInfo>
- <version>1.0.1</version>
- <description>软件升级!!!</description>
- <path>http://192.168.21.96/AVPlayerDemo3.plist</path>
- </updateInfo>
这里path是你的plist文件的路径。
下面来生成ipa和plist
先在summary里写好版本号,与xml文件的版本一致
选择product-》archive
选择最新的那个,然后选择distribute
这里最后主义要勾上“save for Enterprise Distribute”
然后下面Application URL:写上你的ipa要存放的路径,这个路径别人要访问的到。我就放在192.168.21.96服务器下的这个路径了
title我就随便写了
点击保存,我在桌面上生成了AVPlayerDemo3.ipa 和 AVPlayerDemo3.plist
将这两个文件放在服务器下,保证访问路径是path的路径
然后就ok了,访问的改一下
[cpp] view plaincopyprint?
- #pragma mark - alert view delegate
- - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
- {
- //确认下载更新包
- if (buttonIndex == 1) {
- //下载
- [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"itms-services://?action=download-manifest&url=%@",versionPath]]];
- }
- }
0 0
- ios设备版本更新
- 获得ios设备版本
- IOS版本检测,更新版本
- iOS 检测版本更新
- ios检查版本更新
- ios版本更新
- iOS 检测版本更新
- IOS检测版本更新
- IOS版本更新
- ios检查版本更新
- iOS检测版本更新
- iOS 检测版本更新
- ios版本更新
- iOS 版本更新
- iOS 检测版本更新
- IOS 版本更新检测
- iOS 检测版本更新
- iOS 检测版本更新
- erlang lists:keyfind的一个小坑
- 执着女股民:20年炒一只股票 翻几十倍很轻松
- iOS NSNotification的使用 (又学一遍,还有n遍)
- WCF开发实战(一)---创建服务器类
- 编程珠玑学习笔记(1):简单磁盘文件数据排序
- ios设备版本更新
- 关于单片机串口原理
- iOS开发new与alloc/init的区别
- 关于si4438以往犯的一些错误
- iOS-UITableviewCell的重用机制
- u-boot移植启动流程详细分析(2)
- 2014东北农大校赛--A. Paint it! (预处理)
- hdu 2119 Matrix 行列匹配
- 曾经酷爱的Button-小控件解决大问题