Ios development-APP upgrade implementation

Source: Internet
Author: User

Ios development-APP upgrade implementation
Directly run the Code:

/*** Check software upgrade required */-(void) checkVersion {NSURL * url = [NSURL URLWithString: [NSString stringWithFormat: @ http://itunes.apple.com/cn/lookup? Id = % I, iFeverAPPID]; ASIHTTPRequest * request = [[ASIHTTPRequest alloc] initWithURL: url]; [request setUseCookiePersistence: YES]; [request setDelegate: self]; [request setDidFailSelector: @ selector (Response :)]; [request setDidFinishSelector: @ selector (getVersionRequestSuccess :)]; [request startAsynchronous]; // start asynchronous request}-(void) getVersionRequestFailed :( ASIHTTPRequest *) request1 {NSLog (@ from AppSto Re failed to get version information !!);} -(Void) initialize :( ASIHTTPRequest *) request1 {NSString * newVersion; NSData * responseData = [request1 responseData]; NSDictionary * dic = [NSJSONSerialization JSONObjectWithData: responseData options: response error: nil]; NSArray * resultArray = [dic objectForKey: @ results]; for (id config in resultArray) {newVersion = [config valueForKey: @ version];} if (newVersion) {N SLog (@ the version obtained through AppStore is: % @, newVersion);} // obtain the local version NSString * localVersion = [[[NSBundle mainBundle] infoDictionary] objectForKey: @ CFBundleVersion]; NSString * msg = [NSString stringWithFormat: @ your current version is V % @. Check whether to download the new version V % ?, LocalVersion, newVersion]; if ([newVersion floatValue]> [localVersion floatValue]) {UIAlertView * alert = [[UIAlertView alloc] initWithTitle: @ upgrade prompt! Message: msg delegate: self cancelButtonTitle: @ otherButtonTitles: @ upgrade now, nil]; alert. tag = kVersionNeedUpdateAlertTag; [alert show];}

-(Void) alertView :( UIAlertView *) alertView clickedButtonAtIndex :( NSInteger) buttonIndex {if (alertView. tag = kVersionNeedUpdateAlertTag) {// Software Update reminder if (buttonIndex = 1) {NSURL * url = [NSURL URLWithString: [NSString stringWithFormat: @ https://itunes.apple.com/cn/app/wan-zhuan-quan-cheng/id% I? Mt = 8, iFeverAPPID]; [[UIApplication sharedApplication] openURL: url];/* // method 2 to enable iTunes: This method always prompts "unable to connect to itunes ", NSString * iTunesLink = @ itms-apps: // phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftwareUpdate? Id = % I & mt = 8; NSURL * url = [NSURL URLWithString: [NSString stringWithFormat: @ itms-apps: // phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftwareUpdate? Id = % I & mt = 8, iFeverAPPID]; [[UIApplication sharedApplication] openURL: url]; */}

 

If you want to know the information returned when the network requests an AppStore, you can open this link: http://itunes.apple.com/cn/lookup? Id = 465039730

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.