0

我在我的三个应用中进行了应用内购买。一年多以来,第一个工作正常。因为我有这个例程:

-(void)purchaseProUpgrade{
  SKPayment *payment = [SKPayment paymentWithProductIdentifier: inAppProductId];

  if ([SKPaymentQueue canMakePayments]) [[SKPaymentQueue defaultQueue] addPayment:payment];
  else [self purchaseFailedWithError:nil];
}

但是 paymentWithProductIdentifier 已经贬值了。所以在接下来的两个应用程序中,我将其更改为(其余代码相同):

-(void)purchaseProUpgrade{
 SKPayment *payment =[SKPayment paymentWithProduct: self.upgradeProduct];

   if ([SKPaymentQueue canMakePayments]) [[SKPaymentQueue defaultQueue] addPayment:payment];
   else [self purchaseFailedWithError:nil];
}

其中“upgradeProduct”由

- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response{
   NSArray *products = response.products;
   if([products count]>0)  self.upgradeProduct = products[0];

   // the user is warned if upgradeProduct not is set 
}

// upgradeProduct is declared as Strong and I am using ARC.

即使我试图通过来回跳转到购买视图、取消购买等来激发它,这在沙盒中也能正常工作。如果我从应用商店购买我的应用程序,它也能正常工作。我似乎也为大多数用户工作,因为有销售登记。

但是,我几乎每天都会收到崩溃报告,说 [[SKPaymentQueue defaultQueue] addPayment:payment] 因“无效的产品标识符:(null)”而崩溃。在某些情况下,人们似乎已经崩溃,立即重新启动应用程序并尝试再次购买并崩溃。

任何输入表示赞赏。

4

1 回答 1

0

Github 中有一个示例,请查看以下链接

https://github.com/eutterfly/EBPurchase

于 2013-04-29T11:49:09.497 回答