The Kstoreproductviewcontroller class is a subclass of Uiviewcontroller. When you want to show users the products in the App Store, you need to:
1. Instantiate a Skstoreproductviewcontroller class
2. Set its delegate
3. Display the Sotre product view controller to the consumer
The rest is handed over to the operating system. 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. Supports only IOS6.0 and above
Steps:
1. Add Storekit.framework
2. In the header file, add
#import <StoreKit/StoreKit.h>
@interface viewcontroller:uiviewcontroller<skstoreproductviewcontrollerdelegate>
3. Implemented directly in M
-(Ibaction) Action: (UIButton *) Sender {
[Self goappstore:@ "xxxxxx"];//here xxxxx need to be replaced with required AppID
}
-(void) Showappinapp: (NSString *) _appid {
Class Isallow = nsclassfromstring (@ "Skstoreproductviewcontroller");
if (isallow! = nil) {
Skstoreproductviewcontroller *STOREVC = [[Skstoreproductviewcontroller alloc] init];
STOREVC. delegate = self;
[STOREVCLoadproductwithparameters:@{skstoreproductparameteritunesitemidentifier: _appid}
completionblock:^ (BOOL result, Nserror *error) {
if (result) {
[Self presentviewcontroller:_sksvc
Animated:yes
Completion:nil];
}
else{
NSLog (@ "%@", error);
}
}];
}
else{
Less than 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
Processing of a view disappearing
-(void) Productviewcontrollerdidfinish: (Skstoreproductviewcontroller *) Viewcontroller {
[Viewcontroller Dismissviewcontrolleranimated:yes
Completion:nil];
}
Display the App Store's product usage Kstoreproductviewcontroller in your own apple