SKProductsRequest - 如何处理超时/连接错误?

Toa*_*tor 25 iphone objective-c in-app-purchase ios

干杯,

在我看来,SKProductsRequest不会以任何方式处理超时或连接错误.它要么-(void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response在成功的情况下要求其代表,要么不成功.

我想在检索产品时向用户提供某种活动指示,或者如果无法访问appstore,则可能会弹出警报.因为(在失败的情况下)没有来自SKProductsRequest的反馈,但我想知道哪个事件我应该将该反馈的表示联系起来 - 除了等待任意时间.

所以,问题是:是否有一段已知的时间,之后可以安全地假设请求失败了?或者有没有办法检查我刚看不到的待处理请求的状态?

小智 53

我在我的项目中运行它,以便SKRequest失败时(包括SKProductRequest):

- (void)request:(SKRequest *)request didFailWithError:(NSError *)error
{
     alert = [[UIAlertView alloc] initWithTitle:@"In-App Store unavailable" message:@"The In-App Store is currently unavailable, please try again later." delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];

     [alert show];
}
Run Code Online (Sandbox Code Playgroud)

工作一种享受.当然,您可以在括号内放置任何内容来替换我的警报,但这对用户来说很有效.

希望这对你有用.

注意:SKRequestDelegate不在SKProductsRequestDelegate,这有点令人困惑.将SKRequestDelegate用于采购和产品的要求.使用委托集request.delegate可以实现两者的方法.

  • !!!!!! 我不敢相信我没有看到这个...我检查了SKProductDelegate协议一百次因为我认为必须有一个错误处理程序...我想我以前从来没有这么盲目.真棒!非常感谢,老兄! (2认同)