iOS开发中通过 http://itunes.apple.com/lookup?id=app ID 请求应用信息 ,如果你选择了仅限中国地区销售,请使用 http://itunes.apple.com/cn/lookup?id==app ID
/cn代表中国,如果不带,版本号为0 ,内容为空,
另判断当前是否需要更新代码:
NSURL *appUrl = [NSURL URLWithString:[NSString stringWithFormat:@"http://itunes.apple.com/cn/lookup?id=%@",appId]];
NSString *appMsg = [NSString stringWithContentsOfURL:appUrl encoding:NSUTF8StringEncoding error:nil];
NSDictionary*appMsgDict = [selfjsonStringToDictionary:appMsg];
NSDictionary*appResultsDict = [appMsgDict[@"results"]lastObject];
NSString*appStoreVersion = appResultsDict[@"version"];
floatnewVersionFloat = [appStoreVersionfloatValue];//新发布的版本号
NSString *currentVersion = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
floatcurrentVersionFloat = [currentVersionfloatValue];//使用中的版本号
//当前版本小于App Store上的版本&用户未点击不再提示
if(currentVersionFloat
{
}
- (BOOL)isAlertUpdataAgain
{//判断条件,是否选择了不再提示
BOOL res = [[NSUserDefaults standardUserDefaults] objectForKey:@"IS_ALERT_AGAIN"];
returnres;
}