IOS6.0 in-app direct download program does not need to jump appstore-b

Source: Internet
Author: User

Nothing to do. Read the article in the app to create the store environment, do not jump AppStore. The first arbitrary thought: fart. Then curious to go inside to see, originally is IOS6.0 new characteristic, Dayton feeling ashamed. Under study

The Skstoreproductviewcontroller class is a subclass of Uiviewcontroller, and if you are familiar with the view controller, That Skstoreproductviewcontroller is very simple to use. 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. Of course you can't forget only support IOS6.0 and above ~ ~

Steps:

1. Add Storekit.framework

2. In the header file, add

#import

@interface viewcontroller:uiviewcontroller<</span>skstoreproductviewcontrollerdelegate>

3. Implemented 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{
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];


}

IOS6.0 in-app direct download program does not need to jump appstore-b

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.