`
- 浏览:
138821 次
-
- #pragma mark - 检查更新
- - (void)checkUpdateWithAPPID:(NSString *)APPID
- {
-
- NSDictionary *appInfo = [[NSBundle mainBundle] infoDictionary];
- NSString *currentVersion = [appInfo objectForKey:@"CFBundleVersion"];
-
- NSString *updateUrlString = [NSString stringWithFormat:@"http://itunes.apple.com/lookup?id=%@",APPID];
- NSURL *updateUrl = [NSURL URLWithString:updateUrlString];
- versionRequest = [ASIFormDataRequest requestWithURL:updateUrl];
- [versionRequest setRequestMethod:@"GET"];
- [versionRequest setTimeOutSeconds:60];
- [versionRequest addRequestHeader:@"Content-Type" value:@"application/json"];
-
-
- CustomAlertView *checkingAlertView = [[CustomAlertView alloc] initWithFrame:NAVIGATION_FRAME style:CustomAlertViewStyleDefault noticeText:@"正在检查更新..."];
- checkingAlertView.userInteractionEnabled = YES;
- [self.navigationController.view addSubview:checkingAlertView];
- [checkingAlertView release];
-
- [versionRequest setCompletionBlock:^{
-
- [checkingAlertView removeFromSuperview];
-
- NSError *error = nil;
- NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:[versionRequest responseData] options:NSJSONReadingMutableContainers error:&error];
- if (!error) {
- if (dict != nil) {
-
- int resultCount = [[dict objectForKey:@"resultCount"] integerValue];
- if (resultCount == 1) {
- NSArray *resultArray = [dict objectForKey:@"results"];
-
- NSDictionary *resultDict = [resultArray objectAtIndex:0];
-
- NSString *newVersion = [resultDict objectForKey:@"version"];
-
- if ([newVersion doubleValue] > [currentVersion doubleValue]) {
- NSString *msg = [NSString stringWithFormat:@"最新版本为%@,是否更新?",newVersion];
- newVersionURlString = [[resultDict objectForKey:@"trackViewUrl"] copy];
- DLog(@"newVersionUrl is %@",newVersionURlString);
-
-
-
- UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"提示" message:msg delegate:self cancelButtonTitle:@"暂不" otherButtonTitles:@"立即更新", nil nil];
- alertView.tag = 1000;
- [alertView show];
- [alertView release];
- }else
- {
- UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"提示" message:@"您使用的是最新版本!" delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil nil];
- alertView.tag = 1001;
- [alertView show];
- [alertView release];
- }
- }
- }
- }else
- {
- DLog("error is %@",[error debugDescription]);
- }
- }];
-
- [versionRequest setFailedBlock:^{
- [checkingAlertView removeFromSuperview];
-
- CustomAlertView *alertView = [[CustomAlertView alloc] initWithFrame:NAVIGATION_FRAME style:CustomAlertViewStyleWarning noticeText:@"操作失败,请稍候再试!"];
- [self.navigationController.view addSubview:alertView];
- [alertView release];
- [alertView selfRemoveFromSuperviewAfterSeconds:1.0];
- }];
-
- [versionRequest startSynchronous];
- }
-
- - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
- {
- DLog(@"newVersionUrl is %@",newVersionURlString);
- if (buttonIndex) {
- if (alertView.tag == 1000) {
- if(newVersionURlString)
- {
- [[UIApplication sharedApplication] openURL:[NSURL URLWithString:newVersionURlString]];
- }
- }
- }
- }
分享到:
Global site tag (gtag.js) - Google Analytics
相关推荐
vue项目+hbuilder打包实现app自动检测更新并下载vue项目+hbuilder打包实现app自动检测更新并下载
Winform开发的检查更新程序。可用于Winform/WPF,主要功能包括更新文件、更新程序自身、下载安装包等
Electron基于electron-builder进行打包,运行window和Mac上实现检测更新
检测更新软件 API 1.编写version.xml 1 my app name <title>新版本:0.1</title> Test to the latest version, please update! http://yyy.yyy.yyy.yyy/test.apk 2.发布version.xml到...
Android 用Service+OKHttp实现应用后台检测更新示例代码; Android 用Service+OKHttp实现应用后台检测更新示例代码 Android 用Service+OKHttp实现应用后台检测更新示例代码 Android 用Service+OKHttp实现应用后台...
移动端检测更新,调用h5+api实现获取当前webapp的版本号和数据库中版本进行比较,检测更新下载新的安装包
Android检查更新并提示下载安装的例子,比较的简单。客户端检查自己的版本号和服务端的版本号进行比对,如果服务端的版本号大于则提示下载更新,否则无
android 应用更新功能 检测更新 自动下载安装 demo updatedemo
Winform完善检查更新.rar
library必须导入后按照里面的说明文档。。
一个简单小巧的Android检查更新库,通过爬网页的方式查询应用在市场上的最新版本信息
app版本检测更新,实现从service下载,ProgressBar显示下载进度。
易语言自动检测更新!!!! 链接: https://pan.baidu.com/s/1DBdsKp455dzSy4dnmhF0oQ 提取码: iegw
用于android程序自动检测更新,里面包含检测是否有更新,有更新可以选择更新
ipad正在检查更新系统解决方法.docx
app启动检查更新弹窗提示功能的实现
QtAutoUpdater, 自动检查更新并安装它们的Qt库 QtAutoUpdater自动更新库库是一个自动检查更新并安装它们的库。 这里存储库包括:带有基本更新程序的库( 没有任何 GUI )需要第一个库并添加基本的GUI功能的第二 特性...
winform 检查自动更新,方便后续用户自动更新最新的功能,解决成本
一个应用软件的诞生,必将带来的一个问题就是版本的更新问题。今天我就提供一个我个人的方法吧
用于检查本地版本和服务器版本信息对比,有更新则提示更新。仅24KB,无需其他多余控件。