iOS获取当前AppStore版本号与更新
- (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版本号与更新的更多相关文章
- iOS 获取手机型号(已更新至iPhone11)
+ (NSString *)iphoneType { // 需要导入头文件:#import <sys/utsname.h> struct utsn ...
- iOS获取APP的版本号和名称
NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary]; CFShow(infoDictionary); // ap ...
- iOS获取设备型号和App版本号等信息(OC+Swift)
iOS获取设备型号和App版本号等信息(OC+Swift) 字数1687 阅读382 评论3 喜欢10 好久没有写过博客了,因为中间工作比较忙,然后有些个人事情所以耽误了.但是之前写的博客还一直有人来 ...
- iOS 获取appstore 版本
项目上线以后一般都涉及到升级.那么iOS 怎样从appstore获取到版本 事实上非常easy NSString *url = [[NSString alloc] initWithFormat:@&q ...
- ios 获取app版本号
let infoDictionary = Bundle.main.infoDictionary!let appversion = infoDictionary["CFBundleShortV ...
- iOS App上架AppStore 会遇到的坑
前言部分 前言:非原创 文章摘自:http://zhuanlan.zhihu.com/100000PM/20010725 相信大家一定非常「深恶痛疾」AppStore的一系列产品上架规则.每次产品上架 ...
- iOS获取设备型号、装置类型等信息
iOS获取设备型号.设备类型等信息 设备标识 关于设备标识,历史上盛行过很多英雄,比如UDID.Mac地址.OpenUDID等,然而他们都陆陆续续倒在了苹果的门下.苹果目前提供了2个方法供App获取设 ...
- (转))iOS App上架AppStore 会遇到的坑
iOS App上架AppStore 会遇到的坑 前言:非原创 文章摘自:http://zhuanlan.zhihu.com/100000PM/20010725 相信大家一定非常「深恶痛疾」AppS ...
- IOS 获取最新设备型号方法
1.IOS 获取最新设备型号方法列表最新对照表:http://theiphonewiki.com/wiki/Models方法: #import "sys/utsname.h” struct ...
随机推荐
- 犀利的报表系统,发票据与报表开发的快速利器,AgileEAS.NET SOA中间件GReport使用指南
一.前言 AgileEAS.NET SOA 中间件平台是一款基于基于敏捷并行开发思想和Microsoft .Net构件(组件)开发技术而构建的一个快速开发应用平台.用于帮助中小型软件企业建立一条适合市 ...
- 去掉移动端页面 input, textarea, button, a 标签获取焦点时显示的黑影
input, textarea, button, a{ -webkit-tap-highlight-color:rgba(0,0,0,0); }
- LoadRunner 参数和变量的区别(未完)
挺久没来更新了,坚持是件不容易的事呢,之后坚持每天总结下前一天的学习点 在LR中,参数是一种更高级的变量,他们能起到同样的效果,但同时也有几点不同 1. 定义方法不同 (这个还没看懂) 2. 调用语法 ...
- 【html+css】关于页面布局中遇到的问题记录
关于行内元素: 行内元素设置width无效, height无效(可以设置line-height), margin上下无效,padding上下无效,margin和padding可设置左右. text ...
- cdn
cdn内容分发网络: 1. 内容缓存Web cache技术,反向代理 2. 集群服务与负载均衡技术 LVS(四层) 与 nginx(七层) 3. 全局负载均衡工作原理:基于DNS解析的GSLB实现机制 ...
- mac os x 10.10.3 安装protoc
预装如下环境 autoconf 2.6.9automake 1.14libtool 2.4 Building from source Download latest version of procbu ...
- 畅通工程[HDU1863]
畅通工程 Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submissio ...
- java.lang.NoSuchMethodError:
Servlet.service() for servlet [springMVC] in context with path [/mobile] threw exception [Handler pr ...
- openstack-keystone
preparation: config: /etc/keystone/keystone.conf log: /var/log/keystone.log 1. change log level: vi ...
- px与rem关系及转换
PX特点 1. IE无法调整那些使用px作为单位的字体大小:2. 国外的大部分网站能够调整的原因在于其使用了em或rem作为字体单位:3. Firefox能够调整px和em,rem,但是96%以上的中 ...