当用户点击两次购买Iap确认按钮时,使用以下方法分析CRASHES:

Fatal Exception: NSInternalInconsistencyException

"You cannot purchase a product that is in the process of being purchased"

PFPurchase.m line 108

真的要由应用程序来阻止这种情况吗?

[解析1.4.1]

最佳答案

是的,防止这种情况确实是您的责任。

尝试将BOOL pfPurchaseInProgress最初设置为NO的帮助程序类,然后在进行购买时更改它。像这样:

typedef void (^ CompletionBlock)();

(void)buyProduct:(NSString *)productID withCompletionBlock:(CompletionBlock)block
{
    if (!self.pfPurchaseInProgress) {
      self.pfPurchaseInProgress = YES;
      [PFPurchase buyProduct:productID block:^(NSError *error) {
          self.pfPurchaseInProgress = NO;
          if (!error) {
              block();
          }
      }];
    }
}

09-25 22:14