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 ...
随机推荐
- 吃透Javascript数组操作的正确姿势—再读《Js高程》
Javascript中关于数组对象的操作方法比较多也比较杂,正好再次捡起<Javascript高级程序设计>来读,把它们一一总结梳理了一下: 方法类别 方法名称 方法描述 参数 返回值 备 ...
- OneThink开发框架
OneThink是一个开源的内容管理框架,基于最新的ThinkPHP3.2版本开发,提供更方便.更安全的WEB应用开发体验,采用了全新的架构设计和命名空间机制,融合了模块化.驱动化和插件化的设计理念于 ...
- 浏览器-07 chromium 渲染1
Chromium 软件渲染 软件渲染就是利用CPU,根据一定的算法来计算生成网页的内容; Chromium都是用软件渲染的技术来完成页面的绘制工作(除非强行打开硬件加速绘制); 软件渲染基础和架构 R ...
- Delphi 各版本新特性功能网址收集
Delphi XE2 三个新功能介绍举例_西西软件资讯 http://www.cr173.com/html/13179_1.html delphi 2007新功能简介-davidxueer-Chin ...
- 2012 Multi-University #7
最短路+拆点 A As long as Binbin loves Sangsang 题意:从1走到n,每次都是LOVE,问到n时路径是连续多个"LOVE"的最短距离.秀恩爱不想吐槽. 分析:在普通的最 ...
- Skype无法收发组消息
我用微软账户登录的Skype 发现无法收发组消息 - 提示发送消息不可用 卸了重装 - 提示 "无法发送消息, 请尝试获取最新的消息版本, 或者是组内成员使用旧版本无法同时视频和发送 ...
- 【BZOJ】3751: [NOIP2014]解方程
题意 求\(\sum_{i=0}^{n} a_i x^i = 0\)在\([1, m]\)内的整数解.(\(0 < n \le 100, |a_i| \le 10^{10000}, a_n \n ...
- SQL查询到的数据放到DataSet中
public DataTable GetTable(string Id) { StringBuilder strSql = new StringBuilder(); DataSet ds = new ...
- phpcms无刷新分页
控制器添加一个函数: 添加一个静态页面ajax_message.html,在页面中添加如下代码: 在要分页的页面(我的是"show"页面)中添加如上图代码: phpcms无刷新分页 ...
- javascript函数小练习
求n-m之间数据的和 <script> function num(n,m){ var sum=0; for (var i = n; i <= m; i++) { sum+=i; } ...