在应用购买中使用iOS定位特定应用 [英] targeting specific app with iOS in app purchase
问题描述
我在iOS应用商店中有几个付费应用。我想创建一个免费的应用程序,它将显示应用程序商店中每个付费应用程序的预览。
I have several paid apps in the iOS app store. I would like to create a free app that will display a preview of each of the paid apps in the app store.
我已完成免费应用程序。我完全有应用内部分。我迷失了如何定位任何一个付费应用程序。我只看到设置参考名称和产品ID的能力,但是如何将每次购买链接到我现有的一个应用程序?
I have the free app completed. I have the in app portion completely. I am lost on how to target any one of my paid apps. I only see the ability to set up Reference names and Product ID's, but how to "link" each purchase to one of my existing apps?
推荐答案
我相信你正在寻找 SKStoreProductViewController
。
第1步,导入StoreKit:
Step 1, Import StoreKit:
#import <StoreKit/StoreKit.h>
步骤2,符合 SKStoreProductViewControllerDelegate
协议。
@interface ViewController : UIViewController<SKStoreProductViewControllerDelegate>
步骤3,在您方便时显示StoreKit视图控制器:
Step 3, show the StoreKit view controller at your convenience:
SKStoreProductViewController *productVC = [[SKStoreProductViewController alloc] init];
productVC.delegate = self;
NSDictionary *productParameters = @{ SKStoreProductParameterITunesItemIdentifier: @"376558836" };
[productVC loadProductWithParameters:productParameters completionBlock:^(BOOL result, NSError *error) {
if (error) {
// sad face :(
}
if (result) {
[self presentViewController:productVC animated:NO completion:nil];
}
}];
第4步:将376558836更改为您希望用户购买的应用的应用ID。这是我的应用之一。您应该购买它;)
Step 4: Change 376558836 to be the app ID of the apps you want users to buy. That's one of my apps. You should buy it ;)
第5步:获利!
这篇关于在应用购买中使用iOS定位特定应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!