これはiOS 6で導入されたSKStoreProductViewController
でかなり簡単です。そのユーザーはアプリケーション内で他のアプリを購入することができます。
まず、プロジェクトにStoreKit.frameworkを追加します。次に、iTunesを使用してあなたのアプリケーションにリンクするiTunesのURLを探します。 iTunes Storeからリンクをコピーできます。たとえば、AppleのアプリケーションのURLはhttp://itunes.apple.com/de/artist/apple/id284417353?mt=12 です。これには、SKStoreProductViewController
に渡すiTunesの識別子が含まれています。
サンプルコード:
#import "ViewController.h"
#import <StoreKit/SKStoreProductViewController.h>
@interface ViewController()<SKStoreProductViewControllerDelegate>
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
[self showMyApps];
}
-(void)showMyApps
{
SKStoreProductViewController* spvc = [[SKStoreProductViewController alloc] init];
[spvc loadProductWithParameters:@{SKStoreProductParameterITunesItemIdentifier : @284417353}
completionBlock:nil];
spvc.delegate = self;
[self presentViewController:spvc animated:YES completion:nil];
}
-(void)productViewControllerDidFinish:(SKStoreProductViewController *)viewController
{
[self dismissViewControllerAnimated:YES completion:nil];
}
@end
サンプルにリンクを投稿できますか? – alexandresoli
サンプルコードのリンクは次のとおりです。https://developer.apple.com/library/ios/samplecode/TopPaid/Introduction/Intro.html – 4slices
サンプルコードが使用できなくなったようです。メールで送信できますあなたが望むなら、あなたに。 – 4slices