iOS 更新版本

作者: 辉乐轩 | 来源:发表于2016-11-11 17:48 被阅读0次

1. 在AppStore上线的应用(个人或者公司账号 99美元)

在AppDelegate.m中调用 

/**

* 版本升级

*/

[self versionCheckAndUpdate];

实现:

- (void)versionCheckAndUpdate {

// 获取当前版本  只需要Version,不需要Bulid

NSString *newVersion = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];

NSLog(@"%@", newVersion);

// 获取 AppStore版本号

NSString *urlStr = [NSString stringWithFormat:@"http://itunes.apple.com/lookup?id=%@", @"1136975672"];

[self getAppStoreVersionWithpath:urlStr completionHandler:^(NSString *version) {

if (![version isEqualToString:@""]) {

if (![version isEqualToString:newVersion]) {

NSLog(@"有新版本了");

}

} else {

NSLog(@"AppStore没有版本");

}

}];

}

#pragma mark -- 获取数据 --

- (void)getAppStoreVersionWithpath:(NSString *)path completionHandler:(void(^)(NSString *version))completionHandler {

// 使用NSURLSession去请求苹果给的接口,会有很多信息,只取version

NSURL *url = [NSURL URLWithString:path];

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url

cachePolicy:NSURLRequestReloadIgnoringCacheData

timeoutInterval:10];

[request setHTTPMethod:@"POST"];

[[[NSURLSession sharedSession] dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {

NSDictionary *resultDic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers | NSJSONReadingMutableLeaves error:nil];

if ([[resultDic valueForKey:@"resultCount"] intValue]>0) {

NSString *version = [[[resultDic valueForKey:@"results"] firstObject] valueForKey:@"version"];

dispatch_async(dispatch_get_main_queue(), ^{

completionHandler(version);

});

} else {

dispatch_async(dispatch_get_main_queue(), ^{

completionHandler(@"");

});

}

}] resume];

}

2. 企业应用 (299美元)

a. 之前可以用友盟,现在貌似新用户用不了;

b. 说到底,我们只需要一个当前用户正在使用的版本的版本号,然后和当前的版本号比较。写个简单的接口,让后台返回就行 

相关文章

  • iOS版本更新

    iOS APP版本 更新

  • iOS 上传AppStore 被拒汇总

    (1)、苹果要求版本更新必须使用iOS版本更新内置更新机制。 4. Design: Preamble Design...

  • iOS版本更新

    1、获取当前版本 NSString *current_version = [[[NSBundle mainBund...

  • iOS 版本更新

    获取本机版本号 NSDictionary *localDic = [[NSBundle mainBundle] i...

  • iOS版本更新

    版本更新 #pragma mark -检查版本更新 - (void)checkNewVersion { // NS...

  • iOS 版本更新

    众所周知苹果拒绝任何带有版本更新的提示出现在页面中,因此我们通过接口获取,处理是否显示更新提示。 1.判断版本号 ...

  • iOS 版本更新

    1.获取本地版本信息 2.获取App Store版本信息 3.新旧版本对比 代码: 请求的基类中获取App Sto...

  • iOS版本更新

    最近,应项目需求,简单写了一个版本更新的提示,有需要的码友可以去下载看看,实现起来比较简单。 效果图 首先是请求a...

  • iOS版本更新

    一、获取app线上版本苹果提供网址:https://itunes.apple.com/lookup网址所需参数:i...

  • iOS 版本更新

    今天公司要给APP加上“检查更新”这个服务,因为在上一家公司做过,所以没花太多时间就完成了。不过还是看以前公司的代...

网友评论

    本文标题:iOS 更新版本

    本文链接:https://www.haomeiwen.com/subject/pgpfpttx.html