美文网首页
iOS 应用内打开App Store下载页

iOS 应用内打开App Store下载页

作者: brotherGorilla | 来源:发表于2017-06-20 18:12 被阅读49次

    1、导入framework#import
    #import <StoreKit/StoreKit.h>

    2、遵守协议,实现代理方法

    @interface ViewController ()<SKStoreProductViewControllerDelegate>
    /// 取消按钮点击
    - (void)productViewControllerDidFinish:(SKStoreProductViewController *)viewController{
        [self dismissViewControllerAnimated:YES completion:nil];
    }
    

    3、配置SKStoreProductViewController

      NSString *APPID = @"app唯一标识";
      SKStoreProductViewController *storeProductVC = [[SKStoreProductViewController alloc] init];
      storeProductVC.delegate = self;
      NSDictionary *dic = [NSDictionary dictionaryWithObject:APPID forKey:SKStoreProductParameterITunesItemIdentifier];
      [storeProductVC loadProductWithParameters:dic completionBlock:^(BOOL result, NSError * _Nullable error) {
           if (!error) {
                [self presentViewController:storeProductVC animated:YES completion:nil];
           } else {
                 NSLog(@"ERROR:%@",error);
           }
      }];

    相关文章

      网友评论

          本文标题:iOS 应用内打开App Store下载页

          本文链接:https://www.haomeiwen.com/subject/kuraqxtx.html