Open the App Store details page in iOS apps

Source: Internet
Author: User

When you use the iPhone to browse the UC browser's "App Store", you can directly open the App details and download page in the App Store. The effect is as follows: Let's see how to achieve this effect. [Plain] A SKStoreProductViewController object presents a store that allows the user to purchase other media from the App Store. for example, your app might display the store to allow the user to purchase another app. to display a store, create a new SKStoreProductViewController object and set its delegate. then, present the view controll Er modally from another view controller in your app. your delegate dismisses the view controller when the user completes the purchase. to choose a specific product, call the loadProductWithParameters: completionBlock: method, passing the iTunes item identifier for the item you want to upload. as shown in the preceding figure, the App Store product details page is displayed in Modal view mode. I wrote an example according to the instructions in this document. Some code is as follows: [java]-(void) openAppWithIdentifier :( NSString *) appId {SKStoreProductViewController * storeProductVC = [[SKStoreProductViewController alloc] init]; storeProductVC. delegate = self; NSDictionary * dict = [NSDictionary dictionaryWithObject: appId forKey: Snapshot]; [storeProductVC loadProductWithParameters: dict completionBlock: ^ (BOOL result, NSError * error) {if (Result) {[self presentViewController: storeProductVC animated: YES completion: nil] ;}}] ;}in addition, the following proxy method is required: [java] # pragma mark-consumer-(void) productViewControllerDidFinish :( SKStoreProductViewController *) viewController {[viewController dismissViewControllerAnimated: YES completion :^{ [viewController release];} it can be called as follows: [java] [Self openAppWithIdentifier: @ "383037733"]; this code achieves the effect shown above. Note: The StoreKit framework must be added to the project. The above implementation is only supported on devices with iOS 6.0 and later versions. [Java] Framework/System/Library/Frameworks/StoreKit. framework Availability Available in iOS 6.0 and later. to be compatible with devices earlier than 6.0, use the following code (this method will jump out of the current application): [java]-(void) outerOpenAppWithIdentifier :( NSString *) appId {NSString * urlStr = [NSString stringWithFormat: @ "itms-apps: // itunes.apple.com/us/app/id @? Mt = 8 ", appId]; NSURL * url = [NSURL URLWithString: urlStr]; [[UIApplication sharedApplication] openURL: url];}

Related Article

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.