美文网首页
APP程序内部打开某个APP的AppStore页面

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

作者: 曾柏超 | 来源:发表于2017-10-27 20:47 被阅读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
    
    
    
    

    相关文章

      网友评论

          本文标题:APP程序内部打开某个APP的AppStore页面

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