Can I force an iPhone user to upgrade an application?


        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 


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

Which object is create by UIApplicationMain function at app launch time?

The app delegate object is created by UIApplicationMain function at app launch time. The app delegate object's main job is to handle state transitions within the app.

How main function of an app gets called during the app launch cycle?

During app launching, the system creates a main thread for the app and calls the app’s main function on that main thread. The Xcode project's default main function hands over control to the UIKit framework, which takes care of initializing the app before it is run.

Name the application thread from where UIKit classes should be used?

UIKit classes should be used only from an application’s main thread.  Note: The derived classes of UIResponder and the classes which manipulate application’s user interface should be used from application’s main thread.

Does iOS support multitasking?

iOS 4 and above supports multi-tasking and allows apps to remain in the background until they are launched again or until they are terminated