Hello,
This is a follow up question to another question I asked. I have added a pro version in-app purchase to my iOS that will unlock some features on the Watch app. Currently I sent an updateContext to the Apple Watch to tell it that the pro version was purchased. I also use NSUserDefaults on both devices to save the purchase (as a bool == true)
This works fine but has some limitations:
- The Watch has to be paired when the purchase is made
- Deleting the Watch app will require the user to restore the inapp purchase on his iOS app for the context to get resent
- A few more scenarios but I wont go into detail
So I'm thinking to check the in-app purchases on Watch app launch. I can still keep the updateContext functionality as it causes no real harm but I would like to check at launch for in-app purchases.
Is the correct way of doing this pretending to restore purchases on Watch app and doing what needs to be done in the paymentQueueRestoreCompletedTransactionsFinished()
So basically in my extensionDelegate I would do:
func restorePurchases() {
SKPaymentQueue.defaultQueue().addTransactionObserver(self)
SKPaymentQueue.defaultQueue().restoreCompletedTransactions()
}
func paymentQueueRestoreCompletedTransactionsFinished(queue: SKPaymentQueue) {
print("transactions restored")
var purchasedItemsIDs = []
for transaction in queue.transactions {
let tran: SKPaymentTransaction = transaction
let prodID = tran.payment.productIdentifier as String
switch prodID {
case "xxxxx.iap.proversion":
print("restored - pro version")
proVersionPurchased()
default:
print("IAP not setup")
}
}
}