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