【问题标题】:In App Purchase Crashes App应用内购买崩溃应用
【发布时间】:2012-11-10 05:06:15
【问题描述】:

我有一个刚刚提交更新的 iOS 应用。该应用程序的开发版本(模拟器和我的 4S)从未崩溃,并且运行良好。该应用程序今天和 IAP 一样获得批准,但今天早上我意识到 iAP 并未“批准购买”。我刚刚清除它以进行购买,但应用程序仍然崩溃。 iPhone给出的错误(运行应用商店版本)给出了错误:

<Error>: *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayI objectAtIndex:]: index 0 beyond bounds for empty array'

这是发生这种情况的代码:

- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:
(SKProductsResponse *)response
{
    NSArray *myProduct = response.products;
    //this line is where the error occurs
    noAdProduct = [myProduct objectAtIndex:0];
    if (![[[NSUserDefaults standardUserDefaults] objectForKey:@"the id here"] boolValue]) {
        adCell.detailTextLabel.text = [NSString stringWithFormat:@"$%@", noAdProduct.price];
        adCell.userInteractionEnabled = YES;
        adCell.accessoryType = UITableViewCellAccessoryNone;
        adCell.accessoryView = nil;
        [self.tableView reloadData];
    }
}

在请求可用产品列表时会发生这种情况,这显然会在模拟器中返回产品,而不是在应用程序中。我刚刚添加了一个防范措施,但我需要再次将其提交到 App Store。

有谁知道为什么 iAP 没有出现在 App Store 版本中?我是否需要等待“已批准出售”选项才能访问 Apple 的服务器?谢谢!

【问题讨论】:

  • 您登录myProduc了吗?您是否正在注册您的应用内购买标识符?
  • 系统在模拟器上完美运行,但在手机上,数组“response.products”为空。从我在 ITC 中检查“已清除购买”到苹果的服务器开始承认这一点是否有延迟?另外,第二个问题是什么意思。在 ITC 中,它在 iAP 上显示“已批准”
  • [[SKProductsRequest alloc] initWithProductIdentifiers:upgradeIdentifiers]; 您是否在那里注册了您的应用内购买?
  • SKProductsRequest *request= [[SKProductsRequest alloc] initWithProductIdentifiers: [NSSet setWithObject: @"the id"]];
  • @NSAddict 这是应用内购买的 iTunes Connect 屏幕:cl.ly/image/1z3o2p1I0a3B

标签: objective-c iphone in-app-purchase app-store


【解决方案1】:

显然myProduct 数组是空的。为什么会发生这种情况是另一个问题,但在没有确保请求的索引存在的情况下,您永远不应该调用objectAtIndex

if ([myProduct count] > 0)
    noAdProduct = [myProduct objectAtIndex:0];
else
   // Deal with the situation when the array is empty.

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多