objective-c - IAP 问题 - response.products 数组中没有产品

标签 objective-c ios storekit

我对应用内购买有疑问。向服务器发送请求后,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] 是空数组/字典,所以我 抛出错误。

编辑:我做了什么?

  1. 我创建了一个新的 IAP 并将它们与我的应用相关联,我也更改了产品 ID 并在我的 Consts.h 中进行了更改

  2. 我尝试以某种方式将应用程序版本从 1.0 更改为 1.1,这有助于我更改此版本的 IAP。

  3. 仍然无法在我的设备上运行,而在模拟器中有我的 IAP 条目,但我可以测试 - 因为 StoreKit 不允许测试从 sumulator 购买。

  4. 我在我的设备上退出了商店。

最佳答案

如果 [response invalidProductIdentifers] 数组不为空,则表示您的产品无法下载,因此产品数量为空是正常的。只需检查您的响应内容

关于objective-c - IAP 问题 - response.products 数组中没有产品,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11914022/

相关文章:

iphone - 将数据从免费的 iOS 版本复制到我的应用程序的完整版本?

ios - iOS-iOS8中的UISearchBar宽度更改

ios - Objective-C - 将 JSON 数据从 Tableview 传递到另一个 View Controller

ios - 获取 FinishTransaction() 的 SKPaymentTransaction

iphone - 商店套件交易失败

iphone - iOS:路由器IP可达?

ios - Xcode 在 View 可见后加载缓慢的东西

html - 将 HTML 解析为 NSAttributedText - 如何设置字体?

带有多行 UITextField 的 iOS AlertController

iOS 不可再生 IAP - 限制设备数量