我在我的项目中使用应用程序内购买。目前,购买工作正在沙箱中进行。但我发现了一个有关产品标识符的问题。现在我正在对产品标识符进行硬编码,如下所示。我手动将产品标识符存储在 plist (ProductId.plist) 中(请引用图片)
#import "RageIAPHelper.h"
@implementation RageIAPHelper
+ (RageIAPHelper *)sharedInstance {
static dispatch_once_t once;
static RageIAPHelper * sharedInstance;
dispatch_once(&once, ^{
NSString* plistPath = [[NSBundle mainBundle] pathForResource:@"ProductId" ofType:@"plist"];
NSArray * contentArray = [NSArray arrayWithContentsOfFile:plistPath];
NSLog(@"content aray:%@",contentArray);
NSSet * productIdentifiers= [NSSet setWithArray:contentArray];
sharedInstance = [[self alloc] initWithProductIdentifiers:productIdentifiers];
});
return sharedInstance;
}
@end
//应用程序购买教程中来自 RAY WENDERLICH 的代码
现在的问题是我无法从 iTunes Store 动态获取产品标识符。那么我如何从 itunes 商店获取产品 id 而不是在 plist 中进行硬编码??? 请帮忙
最佳答案
您可以执行以下操作来获取产品数据。
NSSet *productIdentifiers = [NSSet setWithObject:@"com.****.******"];
self.productsRequest = [[SKProductsRequest alloc] initWithProductIdentifiers:productIdentifiers];
self.productsRequest.delegate = self;
[self.productsRequest start];
该代表将接到电话,获取您所需的产品信息
- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
关于ios - 在应用程序购买中无法从 iTunes Connect 获取产品标识符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17872384/