首页 > 代码库 > 笔记1客户端应用程序更新版本
笔记1客户端应用程序更新版本
-(void)updataVersion
{
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/javascript"];
[manager GET:APP_URL parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"AFHTTPRequestOperationJSON: %@", responseObject);
// NSDictionary* resultDic=[responseObject.responseData JSONValue];
NSArray* infoArray = [responseObject objectForKey:@"results"];
if (infoArray.count>0) {
NSDictionary* releaseInfo =[infoArray objectAtIndex:0];
NSString* appStoreVersion = [releaseInfo objectForKey:@"version"];
NSDictionary *infoDic = [[NSBundle mainBundle] infoDictionary];
NSString *currentVersion = [infoDic objectForKey:@"CFBundleShortVersionString"];
if (![appStoreVersion isEqualToString:currentVersion])
{
// if (![appStoreVersion isEqualToString:@"1"])
// {
trackViewURL = [[NSString alloc] initWithString:[releaseInfo objectForKey:@"trackViewUrl"]];
NSString* msg =[releaseInfo objectForKey:@"releaseNotes"];
_alertview =[[UIAlertView alloc] initWithTitle:@"版本升级" message:[NSString stringWithFormat:@"%@%@%@", @"新版本特性:",msg, @"\n是否升级?"] delegate:self cancelButtonTitle:@"稍后升级" otherButtonTitles:@"马上升级", nil];
_alertview.delegate = self;
[_alertview show];
}
}
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"AFHTTPRequestOperationError: %@", error);
}];
}
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (alertView == _alertview) {
if (buttonIndex==1)
{
NSLog(@"地址是:%@",[NSURL URLWithString:trackViewURL]);
UIApplication *application = [UIApplication sharedApplication];
[application openURL:[NSURL URLWithString:@"https://itunes.apple.com/us/app/zhao-da-fu/id920323243?l=zh&ls=1&mt=8"]];
}
}
}
#define APP_URL @"http://itunes.apple.com/lookup?id=替换应用id"
//对你有用否请给评价
本文出自 “8594233” 博客,请务必保留此出处http://8604233.blog.51cto.com/8594233/1599680
笔记1客户端应用程序更新版本