调用[SKProductsRequest start]在iOS 4.0上挂起

时间:2023-01-12 23:58:20

Encountering an issue with SKProductsRequest that is specific to iOS 4.0. The problematic code:

遇到特定于iOS 4.0的SKProductsRequest的问题。有问题的代码:

- (void)requestProductData
{
    NSSet *productIdentifiers = [NSSet setWithObjects:kLimitedDaysUpgradeProductId, kUnlimitedUpgradeProductId, nil];

    self.productsRequest = [[SKProductsRequest alloc] initWithProductIdentifiers:productIdentifiers];

    self.productsRequest.delegate = self;

    [self.productsRequest start];
}

- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
{
     NSLog(@"didReceiveResponse");
}

When [SKProductsRequest start] is invoked, the productsRequest:didReceiveResponse: delegate method is never invoked; further, the entire app hangs and is completely unresponsive to input. Obviously, this is a huge issue for our iOS 4.0 users as it not only breaks payments but makes the app completely unusable.

调用[SKProductsRequest start]时,从不调用productsRequest:didReceiveResponse:delegate方法;此外,整个应用程序挂起并完全没有响应输入。显然,对于我们的iOS 4.0用户来说,这是一个巨大的问题,因为它不仅会中断付款,还会使应用程序完全无法使用。

Some other things to note: this only happens on iOS 4.0; iOS 4.2, 3.x are fine. Also: if the delegate is not set on the SKProductsRequest (i.e. comment out the line "self.productsRequest.delegate = self;"), the app doesn't hang (but of course in that case we have no way of getting the product info). Also, the problem still reproduces with everything stripped out of the productsRequest:didReceiveResponse: callback (that method never actually gets called). Finally, if the productIdentifiers NSSet object is initialized to an empty set, the hang doesn't occur.

其他一些注意事项:这只发生在iOS 4.0上; iOS 4.2,3.x很好。另外:如果未在SKProductsRequest上设置委托(即注释掉“self.productsRequest.delegate = self;”行),则应用程序不会挂起(但当然在这种情况下我们无法获取产品信息)。此外,问题仍然存在,一切都被剥夺了productsRequest:didReceiveResponse:callback(该方法实际上从未被调用过)。最后,如果productIdentifiers NSSet对象初始化为空集,则不会发生挂起。

Has anybody else experienced this? Any ideas/thoughts on what could be going on here, and how we might be able to work around this?

有没有人经历过这个?关于这里可能发生什么的任何想法/想法,以及我们如何能够解决这个问题?

2 个解决方案

#1


0  

have you tried implementing –request:didFailWithError: in your delegate, and seeing if that's getting called?

你有没有尝试在你的委托中实现-request:didFailWithError:并看看它是否被调用?

#2


0  

I had a similar problem to this today. No response to any of the delegate methods after I made a SKProductRequest.

今天我遇到了类似的问题。在我创建SKProductRequest之后,没有对任何委托方法的响应。

Everything was working fine, I didn't make any changes to the IAP code yet it broke.

一切都工作正常,我没有对IAP代码进行任何更改,但它破了。

Finally found the problem. If you self reject the app, then the product ID's you made become invalid. We resolved it by resubmitting the app and creating new ID's. Everything started to work again after that.

终于找到了问题。如果您自行拒绝该应用,则您所制作的产品ID将无效。我们通过重新提交应用并创建新ID来解决它。之后一切都开始起作用了。

#1


0  

have you tried implementing –request:didFailWithError: in your delegate, and seeing if that's getting called?

你有没有尝试在你的委托中实现-request:didFailWithError:并看看它是否被调用?

#2


0  

I had a similar problem to this today. No response to any of the delegate methods after I made a SKProductRequest.

今天我遇到了类似的问题。在我创建SKProductRequest之后,没有对任何委托方法的响应。

Everything was working fine, I didn't make any changes to the IAP code yet it broke.

一切都工作正常,我没有对IAP代码进行任何更改,但它破了。

Finally found the problem. If you self reject the app, then the product ID's you made become invalid. We resolved it by resubmitting the app and creating new ID's. Everything started to work again after that.

终于找到了问题。如果您自行拒绝该应用,则您所制作的产品ID将无效。我们通过重新提交应用并创建新ID来解决它。之后一切都开始起作用了。