IOS 判断应用版本和升级提示
2013-08-12 18:50
363 查看
ios中应用的版本判断有两种方法:
1.将你的应用版本号同步在你自己的服务器上,打开程序后去自己的服务器获取版本号和手机上的应用版本号做比较,然后去appstore升级
2.通过url获取appstore上的最新版本信息,然后和手机上的程序版本号做比较,判断是否升级。
最常用的就是方法2,下面讲讲方法2的实现过程。
第一步是去获取appstore上你的应用的版本信息,需要用到的url #define APP_URL @"http://itunes.apple.com/lookup?id=662004496"
(替换id即可),我看网上很多的例子都是同步获取信息,这样会阻塞主线程,我还是觉得异步的比较好。
-(void)checkVersion:(NSString* )appurl
{
ASIFormDataRequest* request=[ASIFormDataRequest requestWithURL:[NSURL URLWithString:appurl]];
[request setRequestMethod:@"POST"];
[request setDelegate:self];
[request startAsynchronous];
}
返回结果是需要使用json解析
这里要讲讲返回的json数据,aapple返回的数据有很多,你看情况选择你需要的数据,一般需要的一个是version,一个是应用新特性releaseNotes,还有一个就是跳转地址 trackViewUrl
artistId =
artistName =
artistViewUrl =
artworkUrl100 =
artworkUrl512 =
artworkUrl60 =
bundleId =
contentAdvisoryRating =
currency =
description =
features =
fileSizeBytes =
formattedPrice =
genreIds =
genres =
ipadScreenshotUrls =
isGameCenterEnabled =
kind =
languageCodesISO2A =
price = 0;
primaryGenreId = 6017;
primaryGenreName =
releaseDate = "2013-08-07T07:03:16Z";
releaseNotes = "1\U3001\U6dfb\U52a0QQ\U8054\U7cfb\U529f\U80fd\n2\U3001\U8bfe\U7a0b\U81ea\U52a8\U64ad\U653e\U65f6\U6e10\U9690\U8fc7\U5ea6\Uff0c\U89c6\U89c9\U6548\U679c\U66f4\U597d\n3\U3001\U4e13\U9898\U6392\U7248\U91cd\U65b0\U8bbe\U8ba1\Uff0c\U4f7f\U4e4b\U66f4\U591a\U7684\U663e\U793a\U4e13\U9898\U4ecb\U7ecd\n4\U3001\U8f6e\U64ad\U56fe\U7247\U52a0\U70b9\U6307\U793a\n5\U3001\U5b66\U9662\U4ecb\U7ecd\U53d8\U6210\U5bcc\U6587\U672c\Uff0c\U53ef\U4ee5\U6d4f\U89c8\U5230\U56fe\U7247\U63cf\U8ff0\n6\U3001\U4fee\U6539\U4e00\U4e9bbug";
screenshotUrls =
sellerName =
supportedDevices =
trackCensoredName =
trackContentRating =
trackId =
trackName =
trackViewUrl = "https://itunes.apple.com/us/app/quan-min-yu-jia-xue-xiao/id662004496?mt=8&uo=4";
version = "1.0.1";
wrapperType =
最后一步就是点击升级后的跳转界面
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex==1)
{
UIApplication *application = [UIApplication sharedApplication];
[application openURL:[NSURL URLWithString:trackViewURL]];
}
}
欢迎您发表您的意见,建议,大家共同学习。
1.将你的应用版本号同步在你自己的服务器上,打开程序后去自己的服务器获取版本号和手机上的应用版本号做比较,然后去appstore升级
2.通过url获取appstore上的最新版本信息,然后和手机上的程序版本号做比较,判断是否升级。
最常用的就是方法2,下面讲讲方法2的实现过程。
第一步是去获取appstore上你的应用的版本信息,需要用到的url #define APP_URL @"http://itunes.apple.com/lookup?id=662004496"
(替换id即可),我看网上很多的例子都是同步获取信息,这样会阻塞主线程,我还是觉得异步的比较好。
-(void)checkVersion:(NSString* )appurl
{
ASIFormDataRequest* request=[ASIFormDataRequest requestWithURL:[NSURL URLWithString:appurl]];
[request setRequestMethod:@"POST"];
[request setDelegate:self];
[request startAsynchronous];
}
返回结果是需要使用json解析
- (void)requestFinished:(ASIHTTPRequest *)request { NSDictionary* resultDic=[request.responseData JSONValue]; NSArray* infoArray = [resultDic 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]) { trackViewURL = [[NSString alloc] initWithString:[releaseInfo objectForKey:@"trackViewUrl"]]; NSString* msg =[releaseInfo objectForKey:@"releaseNotes"]; UIAlertView* alertview =[[UIAlertView alloc] initWithTitle:@"版本升级" message:[NSString stringWithFormat:@"%@%@%@", @"新版本特性:",msg, @"\n是否升级?"] delegate:self cancelButtonTitle:@"稍后升级" otherButtonTitles:@"马上升级", nil]; [alertview show]; } } }
这里要讲讲返回的json数据,aapple返回的数据有很多,你看情况选择你需要的数据,一般需要的一个是version,一个是应用新特性releaseNotes,还有一个就是跳转地址 trackViewUrl
artistId =
artistName =
artistViewUrl =
artworkUrl100 =
artworkUrl512 =
artworkUrl60 =
bundleId =
contentAdvisoryRating =
currency =
description =
features =
fileSizeBytes =
formattedPrice =
genreIds =
genres =
ipadScreenshotUrls =
isGameCenterEnabled =
kind =
languageCodesISO2A =
price = 0;
primaryGenreId = 6017;
primaryGenreName =
releaseDate = "2013-08-07T07:03:16Z";
releaseNotes = "1\U3001\U6dfb\U52a0QQ\U8054\U7cfb\U529f\U80fd\n2\U3001\U8bfe\U7a0b\U81ea\U52a8\U64ad\U653e\U65f6\U6e10\U9690\U8fc7\U5ea6\Uff0c\U89c6\U89c9\U6548\U679c\U66f4\U597d\n3\U3001\U4e13\U9898\U6392\U7248\U91cd\U65b0\U8bbe\U8ba1\Uff0c\U4f7f\U4e4b\U66f4\U591a\U7684\U663e\U793a\U4e13\U9898\U4ecb\U7ecd\n4\U3001\U8f6e\U64ad\U56fe\U7247\U52a0\U70b9\U6307\U793a\n5\U3001\U5b66\U9662\U4ecb\U7ecd\U53d8\U6210\U5bcc\U6587\U672c\Uff0c\U53ef\U4ee5\U6d4f\U89c8\U5230\U56fe\U7247\U63cf\U8ff0\n6\U3001\U4fee\U6539\U4e00\U4e9bbug";
screenshotUrls =
sellerName =
supportedDevices =
trackCensoredName =
trackContentRating =
trackId =
trackName =
trackViewUrl = "https://itunes.apple.com/us/app/quan-min-yu-jia-xue-xiao/id662004496?mt=8&uo=4";
version = "1.0.1";
wrapperType =
最后一步就是点击升级后的跳转界面
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex==1)
{
UIApplication *application = [UIApplication sharedApplication];
[application openURL:[NSURL URLWithString:trackViewURL]];
}
}
欢迎您发表您的意见,建议,大家共同学习。
相关文章推荐
- iOS ——版本更新检测 判断应用版本和升级提示
- IOS 判断应用版本和升级提示
- IOS 判断应用版本和升级提示
- IOS 判断应用版本和升级提示
- iOS如何取得APP的版本信息跟服务器对比进行升级提示?
- 判断浏览器版本是否是ie9以下浏览器,提示升级
- iOS --------- 强制提示用户版本升级
- iOS appStore中的应用 实现版本升级功能
- iOS开发 判断当前APP版本和升级
- 使用if IE语句判断浏览器IE版本及添加升级提示
- iOS 判断版本是否升级,若是有新的版本,提醒升级
- iOS开发中,应用内直接跳转到Appstore(适合版本强制升级和跳转appstore评分)
- iOS如何取得APP的版本信息跟Apple服务器对比进行升级提示?
- WP -- 应用版本升级提示
- iOS 用UIView自定义版本升级提示框
- 判断IE版本并给出提示升级浏览器
- ios开发首次安装或者版本升级的引导页的判断
- iOS 判断当前app版本,升级
- 判断浏览器版本,当浏览器版本过低时提示升级浏览器,不显示原来页面内容
- 判断是否是IE6版本并给出提示升级浏览器