app升级,获取AppStore版本号和本地版本号
来源:互联网 发布:岑村 租房 知乎 编辑:程序博客网 时间:2024/04/27 13:28
1.获取远程版本号
代码:比如随便新建一个demo
- (void)viewDidLoad { [super viewDidLoad]; // 获取appStore版本号 最后一串数字就是当前app在AppStore上面的唯一id NSString *url = [[NSString alloc] initWithFormat:@"http://itunes.apple.com/lookup?id=%@",@"414478124"]; [self Postpath:url];}#pragma mark -- 获取数据-(void)Postpath:(NSString *)path{ NSURL *url = [NSURL URLWithString:path]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:10]; [request setHTTPMethod:@"POST"]; NSOperationQueue *queue = [NSOperationQueue new]; [NSURLConnection sendAsynchronousRequest:request queue:queue completionHandler:^(NSURLResponse *response,NSData *data,NSError *error){ NSMutableDictionary *receiveStatusDic=[[NSMutableDictionary alloc]init]; if (data) { NSDictionary *receiveDic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:nil]; if ([[receiveDic valueForKey:@"resultCount"] intValue]>0) { [receiveStatusDic setValue:@"1" forKey:@"status"]; [receiveStatusDic setValue:[[[receiveDic valueForKey:@"results"] objectAtIndex:0] valueForKey:@"version"] forKey:@"version"]; }else{ [receiveStatusDic setValue:@"-1" forKey:@"status"]; } }else{ [receiveStatusDic setValue:@"-1" forKey:@"status"]; } [self performSelectorOnMainThread:@selector(receiveData:) withObject:receiveStatusDic waitUntilDone:NO]; }]; }-(void)receiveData:(id)sender{ NSLog(@"receiveData=%@",sender); }
说明:上面代码中的这行代码后面那串数字,就是app在AppStore上面的唯一id
NSString *url = [[NSStringalloc]initWithFormat:@"http://itunes.apple.com/lookup?id=%@",@"704253962"];
比如随便在AppStore上面打开一个APP,复制其链接(只要链接中的数字)https://itunes.apple.com/cn/app/wei-xin/id414478124?mt=8
结果:
2.获取本地版本号
NSString* thisVersion = [[NSBundle mainBundle] objectForInfoDictionaryKey: (NSString*)kCFBundleVersionKey];
3.跳转到AppStore下载
//APPid就是上面的那串数字
NSString *urlStr = [NSStringstringWithFormat:@"itms-apps://itunes.apple.com/app/id%@",APPID];
NSURL *url = [NSURLURLWithString:urlStr];
[[UIApplicationsharedApplication]openURL:url];
2 0
- app升级,获取AppStore版本号和本地版本号
- APP升级,获取AppStore版本号和本地版本号--Swift
- iOS 获取appstore 版本号
- iOS 获取appstore 版本号
- iOS开发之获取APP在AppStore中的版本号
- android获取本地版本号
- android app获取版本号,SDK获取版本号
- ios获取app版本号
- 获取app版本号
- ios获取app版本号
- 获取app versionCode版本号
- 如何获取app版本号
- iOS获取App版本号
- iOS_获取app版本号
- 获取app版本号
- 获取APP的版本号
- 获取App当前版本号
- 获取当前app的名称和版本号
- DWVS检测出的常见漏洞
- oracle序列的两个参数:nextval和currval简介
- maven 打jar 包 并将所有依赖打到jar里面
- 解析Qt自带的Style示例
- 【Android】Android Studio 使用第三方类库
- app升级,获取AppStore版本号和本地版本号
- Ignatius and the Princess III(母函数)
- JDOM及DOM4J解析xml文件
- 如何基于OpenShift进行微信公众号开发
- 8 种 NoSQL 数据库系统对比
- activity之间传递对象
- Android-ActionBar
- mysql事务和锁InnoDB
- 网上下载资源的相关文档