我对应用内购买有疑问。向服务器发送请求后,SKProductsRequest
没有返回任何产品。
我这样发送请求:
NSMutableSet *identificators = [[NSMutableSet alloc] init];
[identificators addObject:kInAppPurchaseOneWeekIdentifier];
[identificators addObject:kInAppPurchaseOneMonthIdentifier];
[identificators addObject:kInAppPurchaseSixMonthsIdentifier];
SKProductsRequest *request = [[SKProductsRequest alloc] initWithProductIdentifiers:identificators];
request.delegate = self;
[request start];
[identificators release];
在 Consts.h 中我有那些
// In App Purchase
#define kInAppPurchaseOneWeekIdentifier @"com.astroboxapp.iap.OneWeek"
#define kInAppPurchaseOneMonthIdentifier @"com.astroboxapp.iap.OneMonth"
#define kInAppPurchaseSixMonthsIdentifier @"com.astroboxapp.iap.SixMonths"
我在类里面实现了
-(void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response {
if ( [response.products count] > 0 ) {
// i've do my stuff - show the IAP to the user
} else {
// here goes the error handling
}
}
在我的例子中,[response.products count]
是空数组/字典,所以我
抛出错误。
编辑:我做了什么?
我创建了一个新的 IAP 并将它们与我的应用相关联,我也更改了产品 ID 并在我的 Consts.h 中进行了更改
我尝试以某种方式将应用程序版本从 1.0 更改为 1.1,这有助于我更改此版本的 IAP。
仍然无法在我的设备上运行,而在模拟器中有我的 IAP 条目,但我可以测试 - 因为 StoreKit 不允许测试从 sumulator 购买。
我在我的设备上退出了商店。
最佳答案
如果 [response invalidProductIdentifers] 数组不为空,则表示您的产品无法下载,因此产品数量为空是正常的。只需检查您的响应内容
关于objective-c - IAP 问题 - response.products 数组中没有产品,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11914022/