Return to app from AppStore

Source: Internet
Author: User

The Skstoreproductviewcontroller class is a subclass of Uiviewcontroller,  If you're familiar with View controller, That Skstoreproductviewcontroller is very simple to use. When you want to show users App store products, you need to: 1. Instantiate a Skstoreproductviewcontroller Class 2. Set its delegate3. sotre  The product view controller is displayed to the consumer   the rest is given to the operating system for processing. One point to keep in mind is that Skstoreproductviewcontroller can only be displayed in modal mode. The Skstoreproductviewcontrollerdelegate protocol defines a separate method-productviewcontrollerdidfinish: This method is called when the consumer leaves the App store- This is usually done by clicking the Cancel button in the top left corner of the screen. By sending the Productviewcontrollerdidfinish: message to the agent, the operating system will return control to your program. Of course, you can't forget.   only supports IOS6.0 and above ~~  steps: 1. Add  storekit.framework2.   Plus    #import  < in the header file Storekit/storekit.h> @interface  ViewController : UIViewController< Skstoreproductviewcontrollerdelegate>3. Implement-  directly in M (ibaction) DoAction: (uibutton *) sender {       [self showappinapp:@ "XXXXXX"];//here xxxxx need to be replaced with required appid}-  (void) Showappinapp: (nsstring *) _appid {  class isallow = nsclassfromString (@ "Skstoreproductviewcontroller");  if  (Isallow != nil)  {     skstoreproductviewcontroller *skstoreproductviewcontroller = [[ skstoreproductviewcontroller alloc] init];     Skstoreproductviewcontroller.delegate = self;    [skstoreproductviewcontroller  loadProductWithParameters:@{SKStoreProductParameterITunesItemIdentifier: _appId}                        completionblock:^ (Bool result, nserror *error)  {                         if   (Result)  {                           [self presentviewcontroller:_sksvc                                               animated:YES                                              completion:nil];                         }                          else{                    &nbsP;      nslog (@ "%@", error);                         }                        }];  }  else{    //below IOS6 no this class      nsstring *string = [nsstring stringwithformat:@ "itms-apps://itunes.apple.com/us/app/id%@? Mt=8 ",_appid];    [[uiapplication sharedapplication] openurl:[nsurl  urlwithstring:string]];  }} #pragma  mark - skstoreproductviewcontrollerdelegate / /view disappears processing-  (void) Productviewcontrollerdidfinish: (skstoreproductviewcontroller *) viewcontroller  {  [viewcontroller dismissviewcontrolleranimated:yes                                       completion:nil];}

Return to app from AppStore

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.