In general forcing the user to update our application
mandatorily might not go well from user stand point.
In-spite of the above fact, Sometime you do have to force an Upgrade for security or
other valid reasons. Lot of gaming applications in the market does this sought of updates.
some of the Financial Enterprise apps which are
right there in the App-Store were able to force app users to mandatorily update
it to latest version.
How do i do this?
Get Version info Using Itunes web
service
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:100];
[versionRequest addRequestHeader:@"Content-Type" value:@"application/json"];
[versionRequest startSynchronous];
Response string of our REST call
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"];
}
Compare Both Versions
NSString *version = @"1.0";
if (![version isEqualToString:[itsUserDefaults objectForKey:@"version"]])
{
UIAlertView *createUserResponseAlert = [[UIAlertView alloc] initWithTitle:@"New Version!!" message: @"A new version of app is available to download" delegate:self cancelButtonTitle:nil otherButtonTitles: @”Update", nil];
[createUserResponseAlert show];
[createUserResponseAlert release];//Avoid if using Automatic reference counting
}
Redirect User
-(void)alertView:(UIAlertView *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
NSString *iTunesLink = @"itms-apps://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftwareUpdate?id=<appid>&mt=8";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:iTunesLink]];
}
NSString* jsonResponseString = [versionRequest responseString];
NSDictionary *loginAuthenticationResponse = [jsonResponseString objectFromJSONString];
NSArray *configData = [loginAuthenticationResponse valueForKey:@"results"];
for (id config in configData)
{
version = [config valueForKey:@"version"];
}