반응형

// StoreKit.framework 라이브러리 추가 하기.


// StoreKitDemoViewController.h


#import <UIKit/UIKit.h>
#import <StoreKit/StoreKit.h>

@interface StoreKitDemoViewController : UIViewController <SKStoreProductViewControllerDelegate>

- (IBAction)showStoreView:(id)sender;

@end


// StoreKitDemoViewController.m


#import "StoreKitDemoViewController.h"

@interface StoreKitDemoViewController ()

@end

@implementation StoreKitDemoViewController

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

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

- (IBAction)showStoreView:(id)sender {
   
    SKStoreProductViewController *storeViewController = [[SKStoreProductViewController alloc] init];
    storeViewController.delegate = self;
   
    NSDictionary *parameters = @{SKStoreProductParameterITunesItemIdentifier:[NSNumber numberWithInteger:776483996]}; // 아이디 번호. 앱스토어에서 마우스 오른쪽 클릭시 링크복사후 맨뒤에 아이디 번호임.
   
    [storeViewController loadProductWithParameters:parameters completionBlock:^(BOOL result, NSError *error) {
        if (result)
        {
            [self presentViewController:storeViewController animated:YES completion:nil];
        }
    }];
}

#pragma mark -
#pragma mark SKStoreProductViewControllerDelegate

- (void)productViewControllerDidFinish:(SKStoreProductViewController *)viewController
{
    [viewController dismissViewControllerAnimated:YES completion:nil];
}

@end

반응형
Posted by 컴스터
,