From: http://snowyshell.blog.163.com/blog/static/2209140342013924929888/
APPLE_URL :"http://itunes.apple.com/lookup?id=XXX"
通过检查最新版本和当前版本号,判断是否提醒更新
__block ASIHTTPRequest *request= nil;
request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:APPLE_URL]];
[request setCompletionBlock:^{
NSData *responseData = [request responseData];
NSDictionary *dict =[NSJSONSerialization JSONObjectWithData:responseData options:NSJSONReadingMutableContainers error:nil];
NSLog(@"%@", dict);
if ([dict count] != 0) {
NSString *updateVersion = [[dict valueForKey:@"version"] objectAtIndex:0];
NSLog(@"%@",updateVersion);
NSString *currentVersion = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"];
NSLog(@"%@",currentVersion);
if (![updateVersion isEqualToString:currentVersion]) {
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"有新版本"
message:@"有新版本了,马上去更新吧!"
delegate:self
cancelButtonTitle:@"取消"
otherButtonTitles:@"更新",nil];
[alert show];
[alert release];
}
}
}];
[request setFailedBlock:^{
}];
[request startAsynchronous];
更新/下载地址
"itms-apps://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftwareUpdate?id=XXX&mt=8"
评论地址: