SKStoreProductViewController use, we want to see app or download information, do not want to jump appstore method

Code:

#import <StoreKit/StoreKit.h>
@interface CustomVC ()<SKStoreProductViewControllerDelegate>
{
    SKStoreProductViewController *_storeVC ;
}
@end

@implementation CustomVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
}
#pragma mark SKStoreProductViewControllerDelegate
/**storeVC消失的时候调用的方法*/
- (void)productViewControllerDidFinish:(SKStoreProductViewController *)viewController __TVOS_PROHIBITED NS_AVAILABLE_IOS(6_0){
     NSLog(@"---------------------------------------");
    [_storeVC dismissViewControllerAnimated:YES completion:nil];
}

    
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    
    _storeVC = [SKStoreProductViewController new];
    _storeVC.delegate = self;
    //    storeVC.view.frame = self.view.frame;
    //    [self.view addSubview:storeVC.view];
    
    if (@available(iOS 11.0, *)) {
        NSDictionary *parame = @{SKStoreProductParameterITunesItemIdentifier:@"1467094391"};
        
        
        [_storeVC loadProductWithParameters:parame completionBlock:^(BOOL result, NSError * _Nullable error) {
            //加载成功
            NSLog(@"---------------------------------------%d:%@",result,error);
        }];
    } else {
        // Fallback on earlier versions
    }
    
    [self.navigationController presentViewController:_storeVC animated:YES completion:nil];
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end

 

Guess you like

Origin www.cnblogs.com/hualuoshuijia/p/11493007.html