iOS 实现应用内访问App Store

2018-05-15  本文已影响23人  JohnayXiao

1、导入头文件和声明代理

#import <StoreKit/StoreKit.h>
@interface ViewController () <SKStoreProductViewControllerDelegate>

@end

2、代码

SKStoreProductViewController *appStore = [[SKStoreProductViewController alloc] init];
        appStore.delegate = self;
        // 先去跳转再去加载页面,体验感方面会好很多
        [self presentViewController:appStore animated:YES completion:nil];
        [appStore loadProductWithParameters:@{SKStoreProductParameterITunesItemIdentifier : @"你的appId"} completionBlock:^(BOOL result, NSError * _Nullable error) {
            if (error) {
                NSLog(@"错误 %@",error);
            } else {
            }
        }];

- (void)productViewControllerDidFinish:(SKStoreProductViewController *)viewController {
    [self dismissViewControllerAnimated:YES completion:nil];
}
上一篇下一篇

猜你喜欢

热点阅读