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 ...
随机推荐
- Linux安装Go语言
1.下载Go语言安装包https://storage.googleapis.com/golang/go1.7.1.linux-amd64.tar.gz 2.在命令行执行如下命令: sudo tar - ...
- CSS3混合模式mix-blend-mode/background-blend-mode简介 ,PS中叠加效果
一.CSS3 mix-blend-mode 首先,要知道”blend-mode”就是混合模式的意思.那mix, 恩,我也不知道为什么命名为mix, 可能是该属性不仅可以作用于HTML,还可以作用于SV ...
- openfoam 的安装【转载】
原文地址: http://blog.sina.com.cn/s/blog_14bf001d10102wifw.html OpenFOAM安装 OpenFOAM基于Linux系统下运行,由于对Linux ...
- UVA 12544 - Beehives O(nm) 无向图最小环
Bees are one of the most industrious insects. Since they collect nectarand pollen from flowers, they ...
- TodoMVC中的Backbone+MarionetteJS+RequireJS例子源码分析之二 数据处理
当我们使用jQuery时大部分时间是聚焦于Dom节点的处理,给Dom节点绑定事件等等:前端mvc框架backbone则如何呢? M-Model,Collection等,是聚焦于数据的处理,它把与后台数 ...
- ZeroMQ接口函数之 :zmq_msg_close – 释放一个ZMQ消息
ZeroMQ 官方地址 :http://api.zeromq.org/4-2:zmq_msg_close zmq_msg_close(3) ØMQ Manual - ØMQ/3. ...
- django manytomany
转载:http://my.oschina.net/u/572994/blog/105280 例如有如下模型 models.py ? 1 2 3 4 5 6 7 from django.db impor ...
- 通过hexo+NexT构建静态博客
一般的教程网上有很多,主要讲下我遇到的问题以及解决方法: 一.hexo建立的文档无法上传github deploy: type: git repository: https://github.com/ ...
- ANDROID开发实用小工具
分享一些 Android开发中的实用小工具,你有发现好工具吗? 来这里分享一下呗 一.find bugs 静态检查工具 http://findbugs.sourceforge.net/ FindBug ...
- 2016.9.20 java上课作业
此程序从命令行接收多个数字,求和之后输出