iOS应用自动检查更新提示方法
2015-12-21 13:02
661 查看
NSString *version = @"";
NSURL *url = [NSURL URLWithString:@"http://itunes.apple.com/lookup?id=954270"];
versionRequest = [ASIFormDataRequest requestWithURL:url];
[versionRequest setRequestMethod:@"GET"];
[versionRequest setDelegate:self];
[versionRequest setTimeOutSeconds:150];
[versionRequest addRequestHeader:@"Content-Type" value:@"application/json"];
[versionRequest startSynchronous];
//Response string of our REST call
NSString* jsonResponseString = [versionRequest responseString];
NSDictionary *loginAuthenticationResponse = [jsonResponseString objectFromJSONString];
NSArray *configData = [loginAuthenticationResponse valueForKey:@"results"];
for (id config in configData)
{
version = [config valueForKey:@"version"];
}
//Check your version with the version in app store
if (![version isEqualToString:[itsUserDefaults objectForKey:@"version"]])
{
ProAlertView *createUserResponseAlert = [[ProAlertView alloc]
initWithTitle:@"New Version!!" message: @"A new version of app is
available to download" delegate:self cancelButtonTitle:@"Cancel"
otherButtonTitles: @"Download", nil];
[createUserResponseAlert show];
[createUserResponseAlert release];
}
- (void)alertView:(UIAlertView *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
// the user clicked one of the OK/Cancel buttons
if (buttonIndex == 1)
{
NSString *iTunesLink = @"itms-apps://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftwareUpdate?id=<appid>&mt=8";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:iTunesLink]];
}
}
请求http://itunes.apple.com/lookup?id=954270返回的数据给出的version为2.3, 与本地客户端版本号比较,即可判断有无更新。
通过此方法,我们可以在IOS应用当中提示是否有更新,这样可以让用户安装更新更安全的应用。
NSURL *url = [NSURL URLWithString:@"http://itunes.apple.com/lookup?id=954270"];
versionRequest = [ASIFormDataRequest requestWithURL:url];
[versionRequest setRequestMethod:@"GET"];
[versionRequest setDelegate:self];
[versionRequest setTimeOutSeconds:150];
[versionRequest addRequestHeader:@"Content-Type" value:@"application/json"];
[versionRequest startSynchronous];
//Response string of our REST call
NSString* jsonResponseString = [versionRequest responseString];
NSDictionary *loginAuthenticationResponse = [jsonResponseString objectFromJSONString];
NSArray *configData = [loginAuthenticationResponse valueForKey:@"results"];
for (id config in configData)
{
version = [config valueForKey:@"version"];
}
//Check your version with the version in app store
if (![version isEqualToString:[itsUserDefaults objectForKey:@"version"]])
{
ProAlertView *createUserResponseAlert = [[ProAlertView alloc]
initWithTitle:@"New Version!!" message: @"A new version of app is
available to download" delegate:self cancelButtonTitle:@"Cancel"
otherButtonTitles: @"Download", nil];
[createUserResponseAlert show];
[createUserResponseAlert release];
}
- (void)alertView:(UIAlertView *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
// the user clicked one of the OK/Cancel buttons
if (buttonIndex == 1)
{
NSString *iTunesLink = @"itms-apps://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftwareUpdate?id=<appid>&mt=8";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:iTunesLink]];
}
}
请求http://itunes.apple.com/lookup?id=954270返回的数据给出的version为2.3, 与本地客户端版本号比较,即可判断有无更新。
通过此方法,我们可以在IOS应用当中提示是否有更新,这样可以让用户安装更新更安全的应用。
相关文章推荐
- iOS中怎么转为UTF-8
- ios多线程
- iOS加急审核之2015年总结
- iOS 控件阴影
- iOS 宏(define)与常量(const)的正确使用
- ios 获取当前时间,并转换成时间戳
- 推送证书p12文件转换成pem的命令
- iPhone/iOS开发推送C++服务端APNS源代码
- iOS 使用NSURLConnection
- ios截取图片,并保持图片原有比例,同时填充Imageview
- iOS开发-Xcode Debug、Release、Archive、Profile、Analyze概念解释
- iOS常用加密方法三种
- iOS __block用法
- iOS开发之KVC/KVO
- iOS 中使用GCD怎么让两个线程执行完结束后再去执行另一个线程
- iOS动画
- 完全封装简单的实现图片的圆形剪切效果
- 漫谈iOS程序的证书和签名机制
- ios第三方库的使用
- IOS多线程开发其实很简单