//
// 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
网友评论