Obj-C, Storekit restoreCompletedTransactions retur

2020-05-19 07:08发布

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 ?

2条回答
甜甜的少女心
2楼-- · 2020-05-19 07:23

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];
  }
}
查看更多
狗以群分
3楼-- · 2020-05-19 07:34

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?

查看更多
登录 后发表回答