在APP内给其他APP做推广,经常用到在应用内弹出应用的APP
#import <StoreKit/SKStoreProductViewController.h>
设置代理:<SKStoreProductViewControllerDelegate>
- (void)buttonDidClick:(id)sender { //首先实例化一个VC SKStoreProductViewController *storeVC = [[SKStoreProductViewController alloc] init]; //然后设置代理,注意这很重要,不如弹出就没法dismiss了 storeVC.delegate = self; //接着弹出VC [self presentViewController:storeVC animated:YES completion:nil]; //最后加载应用数据 [storeVC loadProductWithParameters:@{SKStoreProductParameterITunesItemIdentifier:@"1142110895"} completionBlock:^(BOOL result, NSError * _Nullable error) { if (error) { //handle the error } }]; } #pragma mark - SKStoreProductViewControllerDelegate - (void)productViewControllerDidFinish:(SKStoreProductViewController *)viewController { //在代理方法里dismiss这个VC [viewController dismissViewControllerAnimated:YES completion:nil]; }