productsRequest 响应方法未调用
向苹果商店发送请求,
- (void) requestProductData
{
SKProductsRequest *request= [[SKProductsRequest alloc] initWithProductIdentifiers:
[NSSet setWithObjects: featureAId,featureBId,nil]]; // add any other product here
request.delegate = self;
[request start];
}
我正在实施应用内购买,并且我通过响应方法
- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
{
[purchasableObjects addObjectsFromArray:response.products];
}
根本没有被调用。在我尝试的十次尝试中,只有一次它成功了。
I am implementing an in app purchase and I am sending the request to apple store through
- (void) requestProductData
{
SKProductsRequest *request= [[SKProductsRequest alloc] initWithProductIdentifiers:
[NSSet setWithObjects: featureAId,featureBId,nil]]; // add any other product here
request.delegate = self;
[request start];
}
the response method
- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
{
[purchasableObjects addObjectsFromArray:response.products];
}
is not getting called at all. Only once did it call out of ten attempts I tried.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
尝试还实现
- (void)request:(SKRequest *)request didFailWithError:(NSError *)error
方法 - 处理您的请求时可能会出现一些错误。Try to implement also
- (void)request:(SKRequest *)request didFailWithError:(NSError *)error
method - may be there're some errors in processing of your requests.我遇到了同样的问题,但就我而言,原因是我正在使用自动引用计数并且我忘记保留请求。
我的代码是这样的:
但是委托的 productsRequest:didReceiveResponse: 从未被调用。
修复方法是:
I faced the same problem, but in my case the cause was that I was using Automatic Reference Counting and I forgot to retain the request.
My code was like:
But delegate's productsRequest:didReceiveResponse: never got called.
A fix would be:
我也有同样的问题。我创建了一个帮助程序类来处理 IAP 并检查产品。我最终发现我创建的类的实例在响应返回之前被释放,因此委托方法永远不会被调用,因为它们不再存在。
我通过在使用 @proprty(strong, nonatomic) 调用的类中保留辅助类的实例来解决我的问题...
如果您不使用辅助类并将其编码到现有类中,那么上面的答案将通过保留您的 SKProductRequest 来工作。
I had the same problem. I had created a helper class to handle the IAP and check for the products. What I finally found was the instance of the class I created was being released before the response came back, thus the delegate methods never got called because they did not exist anymore.
I solved my problem by retaining the instance of the helper class in the class I called it from using @proprty(strong, nonatomic)...
If you are not using a helper class and coding it into an existing class then the answer above will work by retaining your SKProductRequest.
我也遇到过类似的问题(错误:无法连接到 iTunes Store)。将 iTunes Beta 升级到最新版本后,它再次开始工作。
I've had a similar problem (error: Cannot connect to iTunes Store). After upgrading iTunes Beta to the latest version it started working again.