iOS检查App新版本并更新新版本
检查新版本 更新 第一种方法
//检查新版本 更新
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, ), ^{
// 耗时的操作
//获取本地版本号
NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
NSString *version = [infoDictionary objectForKey:@"CFBundleShortVersionString"];
NSString *build = [infoDictionary objectForKey:@"CFBundleVersion"];
NSString *nowVersion = [NSString stringWithFormat:@"%@.%@", version, build];
//获取appStore网络版本号
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"http://itunes.apple.com/lookup?id=%@", @""]];
NSString * file = [NSString stringWithContentsOfURL:url encoding:NSUTF8StringEncoding error:nil];
NSRange substr = [file rangeOfString:@"\"version\":\""];
NSRange range1 = NSMakeRange(substr.location+substr.length,);
// NSRange substr2 =[file rangeOfString:@"\"" options:nil range:range1];
NSRange substr2 = [file rangeOfString:@"\"" options:NSCaseInsensitiveSearch range:range1];
NSRange range2 = NSMakeRange(substr.location+substr.length, substr2.location-substr.location-substr.length);
NSString *appStoreVersion =[file substringWithRange:range2];
dispatch_async(dispatch_get_main_queue(), ^{
// 更新界面
//如果不一样去更新
if(![nowVersion isEqualToString:appStoreVersion])
{
[self showAlert];
}
});
});
/**
* 检查新版本更新
*/
-(void)showAlert
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"有新的版本啦~~" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"前去更新",nil];
[alert show];
}
- (void)alertView:(UIAlertView*)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if(buttonIndex==)
{
// 此处加入应用在app store的地址,方便用户去更新,一种实现方式如下:
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"https://itunes.apple.com/us/app/id%@?ls=1&mt=8", @""]];
[[UIApplication sharedApplication] openURL:url];
}
}
检查新版本 更新 第二种方法
// 获取appStore版本号
NSString *url = [[NSString alloc] initWithFormat:@"http://itunes.apple.com/lookup?id=%@",@""]; [self Postpath:url]; #pragma mark -- 获取数据
-(void)Postpath:(NSString *)path
{ NSURL *url = [NSURL URLWithString:path];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url
cachePolicy:NSURLRequestReloadIgnoringCacheData
timeoutInterval:]; [request setHTTPMethod:@"POST"]; NSOperationQueue *queue = [NSOperationQueue new]; [NSURLConnection sendAsynchronousRequest:request queue:queue completionHandler:^(NSURLResponse *response,NSData *data,NSError *error){
NSMutableDictionary *receiveStatusDic=[[NSMutableDictionary alloc]init];
if (data) { NSDictionary *receiveDic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:nil];
if ([[receiveDic valueForKey:@"resultCount"] intValue]>) { [receiveStatusDic setValue:@"" forKey:@"status"];
[receiveStatusDic setValue:[[[receiveDic valueForKey:@"results"] objectAtIndex:] valueForKey:@"version"] forKey:@"version"];
}else{ [receiveStatusDic setValue:@"-1" forKey:@"status"];
}
}else{
[receiveStatusDic setValue:@"-1" forKey:@"status"];
} [self performSelectorOnMainThread:@selector(receiveData:) withObject:receiveStatusDic waitUntilDone:NO];
}]; } -(void)receiveData:(id)sender
{
NSLog(@"receiveData=%@",sender); } 最后打印出来的字典中就包含 版本号 receiveData={
status = ;
version = "1.0.0";
}
iOS检查App新版本并更新新版本的更多相关文章
- iOS 检查app版本更新操作
iOS 检查app版本更新操作 1:获取本地安装的版本信息: [NSString stringWithFormat:@"Version %@ (%@)", [[[NSBundle ...
- ios 在APP内提示更新
http://www.jianshu.com/p/24daf5147bda ios如何在应用内部提示更新 两颗星 http://www.jianshu.com/p/2ba10a58bb02 ...
- iOS - 利用 iTunes 接口检查 App 版本更新
iOS 想要检查 App 当前版本是否为最新,一般的方案大概都是服务器自己提供一个接口来获取 App 最新版本是多少,然后再做出相应提示是否需要更新,但是接口需要手动维护,应用要审核,还得等审核通过以 ...
- 解决“iOS 7 app自动更新,无法在app中向用户展示更新内容”问题
转自cocoachina iOS 7能在后台自动app,这对开发者来说和用户都很方便,但是还是有一些缺点.用户不会知道app本次更新的内容,除非他们上到app的App Store页面去查看.开发者也会 ...
- iOS 利用 Framework 进行动态更新
http://nixwang.com/2015/11/09/ios-dynamic-update/ 前言 目前 iOS 上的动态更新方案主要有以下 4 种: HTML 5 lua(wax)hotpat ...
- [App Store Connect帮助]一、 App Store Connect 使用入门(4)iOS 版 App Store Connect
通过 iOS 版 App Store Connect,您可以在移动设备上查看销售数据.App 元数据和顾客评论.您还可以检查 App 状态.发布您 App 的新版本并回应“Resolution Cen ...
- 最全APP安装/卸载/更新测试点
1.安装查看在安装过程中存在的提示信息是否明确,意思是否明确在安装过程中,点击取消按钮,能否正常退出安装程序,软件是否可用.安装时是否识别有SD卡,并默认安装到sd卡中安装过程中,接听电话或者短信,安 ...
- iOS的APP验证版本更新方法
一个老项目没有集成自动检测及提示用户更新新版本的功能,自己在网上查资料捣鼓出自己的方法,可能比较粗陋,希望大家多多指导,我们的项目的版本号是X.X.X的格式,所以直接把字符串转换成float类型的值无 ...
- android 检查软件是否有更新版本
import java.net.HttpURLConnection; import java.net.URL; import java.util.HashMap; import com.yuxin.m ...
随机推荐
- 构建自己的PHP框架--实现Model类(2)
在上一篇博客中我们简单实现了findOne方法,但我们可以看到,还是有一些问题的,下面我们来修正一下这些问题. 首先是返回的数据中,数字被转换成了字符串.我们需要的是数字啊... PDO中有属性可以支 ...
- mysql乐观锁总结和实践--转
原文地址:http://chenzhou123520.iteye.com/blog/1863407 上一篇文章<MySQL悲观锁总结和实践>谈到了MySQL悲观锁,但是悲观锁并不是适用于任 ...
- iOS 保持界面流畅的技巧 (转载)
这篇文章会非常详细的分析 iOS 界面构建中的各种性能问题以及对应的解决思路,同时给出一个开源的微博列表实现,通过实际的代码展示如何构建流畅的交互. Index 演示项目 屏幕显示图像的原理 卡顿产生 ...
- C语言 第八章 函数、指针与宏
一.函数 函数是一个包含完成一定功能的执行代码段.我们可以把函数看成一个"黑盒子", 你只要将数据送进去就能得到结果, 而函数内部究竟是如何工作的的, 外部程序是不知道的.外部程序 ...
- Front End Developer Questions 前端开发人员问题(三)JavaScript部分
问题来源:http://markyun.github.io/2015/Front-end-Developer-Questions/ 三.javascript1.介绍JavaScript的基本数据类型. ...
- 简析Geoserver中获取图层列表以及各图层描述信息的三种方法
文章版权由作者李晓晖和博客园共有,若转载请于明显处标明出处:http://www.cnblogs.com/naaoveGIS/. 1.背景 实际项目中需要获取到Geoserver中的图层组织以及各图层 ...
- jQuery-1.9.1源码分析系列(十一) DOM操作
DOM操作包括append.prepend.before.after.replaceWith.appendTo.prependTo.insertBefore.insertAfter.replaceAl ...
- 8.2 使用Fluent API进行实体映射【Code-First系列】
现在,我们来学习怎么使用Fluent API来配置实体. 一.配置默认的数据表Schema Student实体 using System; using System.Collections.Gener ...
- 【非原创】IOS 验证文字是否是中文
从环信中找到的部分不错的代码,拿出来记录一下 是否是中文 -(BOOL)isChinese{ NSString *match=@"(^[\u4e00-\u9fa5]+$)"; NS ...
- Redis命令拾遗四——集合类型(命令补充)
补充下上篇文章集合的命令. 上篇地址 博客园蜗牛 http://www.cnblogs.com/tdws/p/5785939.html SCARD Key获得执行集合中元素的数量. SDIFFSTOR ...