- (void)checkUpdateWithAppID:(NSString *)appID success:(void (^)(NSDictionary *resultDic , BOOL isNewVersion ,NSString * newVersion , NSString * currentVersion))success failure:(void (^)(NSError *error))failure{
AFHTTPSessionManager *manager = [AFHTTPSessionManagermanager];
manager.requestSerializer=[AFHTTPRequestSerializerserializer];
manager.responseSerializer=[AFHTTPResponseSerializerserializer]; //
NSString *encodingUrl=[[@"http://itunes.apple.com/lookup?id=" stringByAppendingString:@"APP的唯一ID"]stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; [manager GET:encodingUrl parameters:nilprogress:^(NSProgress *_Nonnull downloadProgress) { } success:^(NSURLSessionDataTask *_Nonnull task, id _Nullable responseObject) { NSDictionary *resultDic=[NSJSONSerializationJSONObjectWithData:responseObject options:NSJSONReadingMutableLeaveserror:nil]; //获取AppStore的版本号
NSString * versionStr =[[[resultDic objectForKey:@"results"]objectAtIndex:]valueForKey:@"version"]; NSString *versionStr_int=[versionStr stringByReplacingOccurrencesOfString:@"."withString:@""]; int version=[versionStr_intintValue]; //获取本地的版本号
NSDictionary *infoDic=[[NSBundle mainBundle] infoDictionary]; NSString * currentVersion = [infoDic valueForKey:@"CFBundleShortVersionString"]; NSString *currentVersion_int=[currentVersion stringByReplacingOccurrencesOfString:@"."withString:@""]; int current=[currentVersion_int intValue]; if(version>current){
success(resultDic,YES, versionStr,currentVersion);
}else{
success(resultDic,NO ,versionStr,currentVersion);
}
} failure:^(NSURLSessionDataTask *_Nullable task, NSError *_Nonnull error) {
failure(error);
}];
} // 调用 VersionUpdate *tool=[[VersionUpdatealloc]init];
__weaktypeof(self)weakSelf=self;
[tool checkUpdateWithAppID:@""success:^(NSDictionary *resultDic,BOOL isNewVersion, NSString *newVersion , NSString * currentVersion) {
if (isNewVersion) {//表示要更新版本
NSMutableDictionary *dict=[[NSMutableDictionary alloc]init];
NSString *key=[NSString stringWithFormat:@"%@%@",currentVersion,newVersion];
NSString *value=[s.versionUpdateMessage objectForKey:key];
int time =[value intValue];
if (time<&&_versionUpdateVC==nil) {//小于三次可以继续弹框
time+=;
[dict setValue:[NSString stringWithFormat:@"%d",time]forKey:key];
s.versionUpdateMessage=[NSDictionary dictionaryWithDictionary:dict];
_versionUpdateVC = [[VersionUpdateController alloc]initWithContent:[[[resultDic objectForKey:@"results"]firstObject]objectForKey:@"releaseNotes"]];//releaseNotes,AppStore上面的APP更新内容
[_versionUpdateVC addSelfFromSuperWithVersionStr:newVersion];
}else{//大于三次不做任何操作
[weakSelf joinGroupView];
}
}
} failure:^(NSError *error) {
[weakSelf joinGroupView];
}];

iOS获取当前AppStore版本号与更新的更多相关文章

  1. iOS 获取手机型号(已更新至iPhone11)

    + (NSString *)iphoneType {            //    需要导入头文件:#import <sys/utsname.h>        struct utsn ...

  2. iOS获取APP的版本号和名称

    NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary]; CFShow(infoDictionary); // ap ...

  3. iOS获取设备型号和App版本号等信息(OC+Swift)

    iOS获取设备型号和App版本号等信息(OC+Swift) 字数1687 阅读382 评论3 喜欢10 好久没有写过博客了,因为中间工作比较忙,然后有些个人事情所以耽误了.但是之前写的博客还一直有人来 ...

  4. iOS 获取appstore 版本

    项目上线以后一般都涉及到升级.那么iOS 怎样从appstore获取到版本 事实上非常easy NSString *url = [[NSString alloc] initWithFormat:@&q ...

  5. ios 获取app版本号

    let infoDictionary = Bundle.main.infoDictionary!let appversion = infoDictionary["CFBundleShortV ...

  6. iOS App上架AppStore 会遇到的坑

    前言部分 前言:非原创 文章摘自:http://zhuanlan.zhihu.com/100000PM/20010725 相信大家一定非常「深恶痛疾」AppStore的一系列产品上架规则.每次产品上架 ...

  7. iOS获取设备型号、装置类型等信息

    iOS获取设备型号.设备类型等信息 设备标识 关于设备标识,历史上盛行过很多英雄,比如UDID.Mac地址.OpenUDID等,然而他们都陆陆续续倒在了苹果的门下.苹果目前提供了2个方法供App获取设 ...

  8. (转))iOS App上架AppStore 会遇到的坑

    iOS App上架AppStore 会遇到的坑   前言:非原创 文章摘自:http://zhuanlan.zhihu.com/100000PM/20010725 相信大家一定非常「深恶痛疾」AppS ...

  9. IOS 获取最新设备型号方法

    1.IOS 获取最新设备型号方法列表最新对照表:http://theiphonewiki.com/wiki/Models方法: #import "sys/utsname.h” struct ...

随机推荐

  1. [译]:Orchard入门——导航与菜单

    原文链接:Navigation and Menus 文章内容基于Orchard1.8版本.同时包含Orchard 1.5之前版本的导航参考 Orchard有许多不同的方法来创建菜单.本文将介绍两种较为 ...

  2. MVC 好记星不如烂笔头之 ---> 全局异常捕获以及ACTION捕获

    public class BaseController : Controller { /// <summary> /// Called after the action method is ...

  3. mysql中,通过脚本设置表的自增列,及自增步长

    设置自增列(其实通过navicate可以直接设置的,也方便:要不然可能需要删除列了) ALTER TABLE `domain_dns_tucows` CHANGE `id` `id` INT(11) ...

  4. HYSBZ 2957 分块

    题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=2957 题意:中文题面 思路: 来自此博客 首先明确问题,对于每栋楼房的斜率K=H/X,问题 ...

  5. HDU-1203(01背包)

    I NEED A OFFER! Problem Description Speakless 很早就想出国,现在他已经考完了所有需要的考试,准备了所有要准备的材料,于是,便需要去申请学校了.要申请国外的 ...

  6. Unity Standard Assets 简介之 CrossPlatformInput

    这篇介绍跨平台输入工具包CrossPlatformInput,主要包括 Prefabs 和 Scripts 两个文件夹: 由于该包中的脚本联系比较紧密,都是配合着去实现特定的功能,没有太大的独立可重用 ...

  7. HDU5942 : Just a Math Problem

    \[\begin{eqnarray*}ans&=&\sum_{i=1}^ng(i)\\&=&\sum_{i=1}^n\sum_{d|i}\mu^2(d)\\&= ...

  8. SSH三大框架的JAR包下载地址

    官网的英文网站读起来有点费劲,把下载地址直接放到这儿,以后免得到处找了 Struts 2 : http://struts.apache.org/download.cgi#struts216 sprin ...

  9. CSS的Hack技术

    主要是用来解决兼容性的特殊方法: IE都能识别*;标准浏览器(如FF)不能识别*: IE6能识别*,但不能识别 !important, IE7能识别*,也能识别!important,还有# FF不能识 ...

  10. 基于华清远见STM32f051的 IIC从模式实现方法

    作者:卢老师,华清远见嵌入式学院讲师. 在大多情况下,我们使用MCU控制传感器,节点以及相关从设备,但在较为复杂的系统中,有时候也会使用MCU做为从设备. 下面是关于stm32f051的从模式实现方法 ...