2

**Edit: I've narrowed down the cause to a purchase having Apple Hosted Content. Regular purchases that aren't hosted content are restored properly.

I can't seem to restore purchases on my app. Purchases work completely fine. However when I use a function that calls:

SKPaymentQueue.default().restoreCompletedTransactions()

The payment queue is never called

func paymentQueue(_ queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction]) {
    //Not called!
}

The paymentQueue has no problems for regular purchases.

It looks like the restore is completing properly because after running the above .restoredCompletedTransactions I immediately get this function called.

func paymentQueueRestoreCompletedTransactionsFinished(_ queue: SKPaymentQueue) {       
print ("This works")  
}

I also checked with the following and get no error:

func paymentQueue(_ queue: SKPaymentQueue, restoreCompletedTransactionsFailedWithError error: Error) 

The SKPaymentQueue.add(self) is called way before the restoredCompletedTransactions, so this also shouldn't be an issue.

What could cause IAP working perfectly fine, but not the restore? I am testing it from a physical device, and using a sandbox account.

This recent question had a similar problem, but never got an answer. Also, I'm not sure if it matters, but the purchases are using Apple Hosted Content.

Any help would be super appreciated! It's killing me here.

Adam S.
  • 173
  • 3
  • 15
  • I think `paymentQueueRestoreCompletedTransactionsFinished(_:)` is the correct call back. Sounds like restore is working. Maybe you just need to re-validate the receipt? – picciano May 16 '18 at 21:54
  • That callback is the correct method to let you know that the restoration process is complete, but that method will be called even if there were no purchases to restore. – Paulw11 May 16 '18 at 22:05
  • @Paulw11 Ah okay that makes sense for that method. So what could cause it to say there are no purchases to restore when there are (if I try to repurchase an item, I get the "you've already purchased this" message), and why wouldn't it call the Payment Queue method like it should? – Adam S. May 16 '18 at 22:18
  • @picciano But shouldn't it run the Payment Queue Updated Transactions before I would need to re-validate a receipt? – Adam S. May 16 '18 at 22:19

1 Answers1

0

So I sort of figured it out.

I deleted all the in app purchases from iTunes Connect, and recreated them (with hosted content), and it fixed the issue.

I think the issue might have been that I had changed the bundle identifier at some point after I already created the in app purchases. While I had adjusted the IDs of the product and the code to the new bundle identifier, I wonder if the original purchase history of these were trying to be restored, and since those original purchases used the old bundle identifier, they wouldn't load as transactions.

Adam S.
  • 173
  • 3
  • 15