Obj-C, Storekit restoreCompletedTransactions returns zero transactions?

旧时模样 提交于 2019-12-03 06:51:10

问题


I'm having some problems restoring completed transactions.

[[SKPaymentQueue defaultQueue] restoreCompletedTransactions];

I've added the observer mentioned in several examples, I've tried adding paymentQueueRestoreCompletedTransactionsFinished and already have updatedTransactions. paymentQueueRestoreCompletedTransactionsFinished says I have zero transactions.

I can buy a product and if I try to buy again, it stops me and says I've already bought the product, using this code.

SKPayment *payment = [SKPayment paymentWithProductIdentifier:productIdentifier];
[[SKPaymentQueue defaultQueue] addPayment:payment];

I thought maybe I had a problem with my bundle identifier, but that seems fine and the buy wouldn't work if it wasn't.

I have been trying this on the device as well as the simulator, but this has the same result. Also, it doesn't make a difference If I'm using UK or US store.

I'm really grasping at straws to find out why this doesn't work for me ?


回答1:


try to do it like this and check the array count is it return zero also ?

- (void) checkPurchasedItems
{
   [[SKPaymentQueue defaultQueue] restoreCompletedTransactions];
}//You Call This Function

//Then this delegate Function Will be fired
- (void) paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue
{
  purchasedItemIDs = [[NSMutableArray alloc] init];

  NSLog(@"received restored transactions: %i", queue.transactions.count);
  for (SKPaymentTransaction *transaction in queue.transactions)
  {
      NSString *productID = transaction.payment.productIdentifier;
      [purchasedItemIDs addObject:productID];
  }
}



回答2:


According to the docs:

When you create a new product to be sold in your store, you choose whether that product can be restored or not.

So the question is, is your product configured to allow restores?



来源:https://stackoverflow.com/questions/10120050/obj-c-storekit-restorecompletedtransactions-returns-zero-transactions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!