gpt4 book ai didi

iphone - 我可以强制 iPhone 用户升级应用程序吗?

转载 作者:行者123 更新时间:2023-12-03 18:10:47 28 4
gpt4 key购买 nike

一旦 iTunes Store 中有我的应用程序的新版本可用,是否可以强制用户升级?

我目前正在开发一个应用程序。但是,每当我上传较新的版本时,我想强制升级,因为升级将具有更多功能,并且我想放弃以前的版本。 iPhone 默认情况下可以这样做吗?还是我必须编写自己的实现来检查当前版本并将其与商店进行比较?

最佳答案

我通过从 itunes webservice 获取版本并与当前版本进行比较来完成此功能。以下是我的代码

        NSString *version = @"";
NSURL *url = [NSURL URLWithString:@"http://itunes.apple.com/lookup?id=<Your app ID>"];
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];
}

并将应用程序 ID 放入 itunes 链接中,请参阅下面的代码..

- (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]];
}
}

注意:您需要 JSONKit 框架和 ASIHttp 框架才能进行 Web 服务调用。

关于iphone - 我可以强制 iPhone 用户升级应用程序吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2221436/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com