APP程序内部打开某个APP的AppStore页面

2017-10-27  本文已影响0人  曾柏超

//
//  ViewController.m
//  innerAppStore
//
//  Created by 柏超曾 on 2017/10/27.
//  Copyright © 2017年 柏超曾. All rights reserved.
//

#import "ViewController.h"
#import <StoreKit/StoreKit.h>


@interface ViewController () <SKStoreProductViewControllerDelegate>


@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}


-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{


    [self openAppWithIdentifier:@"1212104959"];//AppID可以在iTunesconnect中

}


- (void)openAppWithIdentifier:(NSString*)appId{
    
      SKStoreProductViewController * storeProductVC = [[SKStoreProductViewController alloc] init];
    
     storeProductVC.delegate = self;
    
     NSDictionary * dict = [NSDictionary dictionaryWithObject:appId forKey:SKStoreProductParameterITunesItemIdentifier];
    
    [storeProductVC loadProductWithParameters:dict completionBlock:^(BOOL result,NSError*error) {
        
       if(result) {
            
          [self presentViewController:storeProductVC animated:YES completion:nil];
            
       }
        
    }];
    
    
    
}

#pragma mark -协议方法

- (void)productViewControllerDidFinish:(SKStoreProductViewController*)viewController{
    
     NSLog(@"关闭界面");
    
    [viewController dismissViewControllerAnimated:YES completion:nil];
    
}




- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end



上一篇 下一篇

猜你喜欢

热点阅读