iOS应用版本更新
来源:互联网 发布:php实现注册登录 编辑:程序博客网 时间:2024/05/01 15:00
#import "AppDelegate.h" application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//ios应用版本更新
[selfVersionClick];
returnYES;
}
Version
//更新实现方法
-(void)VersionClick{
//获取发布版本的Version,id替换成自己应用的id
NSString *string = [NSStringstringWithContentsOfURL:[NSURLURLWithString:@"http://itunes.apple.com/lookup?id=662004496"]encoding:NSUTF8StringEncodingerror:nil];
if (string !=nil && [stringlength]>0 && [stringrangeOfString:@"version"].length==7) {
[selfcheckAppUpdata:string];
}
}
比较当前版本与新上线版本做比较
#pragma mark ---比较当前版本与新上线版本做比较
-(void)checkAppUpdata:(NSString *)appInfo{
//获取当前版本
NSString *version = [[[NSBundlemainBundle] infoDictionary]objectForKey:@"CFBundleVersion"];
NSString *appInfo1 = [appInfosubstringFromIndex:[appInfo rangeOfString:@"\"version\":"].location +10];
appInfo1 = [[appInfo1 substringToIndex:[appInfo1rangeOfString:@","].location]stringByReplacingOccurrencesOfString:@"\""withString:@""];
//判读,如果不同,则进入更新
if (![appInfo1isEqualToString:version]) {
NSLog(@"新版本:%@,当前版本:%@",appInfo1,version);
if ([[UIDevicecurrentDevice].systemVersionintValue] >= 9.0) {
UIAlertController *alertController = [UIAlertControlleralertControllerWithTitle:nilmessage:[NSStringstringWithFormat:@"新版本 %@已发布!",appInfo1]preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *cancelAction = [UIAlertActionactionWithTitle:@"知道了"style:UIAlertActionStyleCancelhandler:^(UIAlertAction *action) {
}];
UIAlertAction *otherAction = [UIAlertActionactionWithTitle:@"前往更新"style:UIAlertActionStyleDefaulthandler:^(UIAlertAction *action) {
[selfUpdata];
}];
[alertController addAction:cancelAction];
[alertController addAction:otherAction];
}else
{
UIAlertView *alert = [[UIAlertViewalloc] initWithTitle:nilmessage:[NSStringstringWithFormat:@"新版本 %@已发布!",appInfo1]delegate:selfcancelButtonTitle:@"知道了"otherButtonTitles:@"前往更新",nil];
alert.delegate =self;
[alert show];
}
}
}
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
if (buttonIndex ==1 ) {
[selfUpdata];
}
}
-(void)Updata{
NSString *url =@"";//填写自己应用的更新地址
[[UIApplicationsharedApplication] openURL:[NSURLURLWithString:url]];
}
- iOS应用版本更新
- iOS 应用版本检测更新
- iOS应用版本更新(自动提醒用户更新代码)
- ios coreData 根据应用版本升级进行更新
- 关于ios上应用版本更新的一些小结
- iOS开发企业版应用版本更新的实现
- IOS应用版本更新(自动提醒用户)
- iOS应用版本更新(自动提醒用户)
- iOS版本更新到10.3无法下载企业应用
- 应用上传,更新版本
- Android应用版本更新
- 应用版本更新Xutils3
- IOS版本检测,更新版本
- iOS 检测版本更新
- ios检查版本更新
- ios版本更新
- iOS 检测版本更新
- IOS检测版本更新
- dom操作表格示例(dom创建表格)
- dom操作表格示例(dom创建表格)
- 电脑无法连接无线网
- Mybatis 大数据量的批量insert解决方案
- Centos下Tomcat以指定的用户,非root权限开机自启
- iOS应用版本更新
- html DOM操作表格及样式
- 对char **argv的理解(多级指针)
- MySQL数据库update更新子查询[Err] 1093 - You can't specify target table 'text' for update in FROM clause
- Oracle统计信息
- Mongodb-1
- 不让浏览器缓存js
- iOS 绘制虚线
- HTML DOM Table 对象