Re: restoreCompletedTransactions() not working

I am trying to restore Non-Consumable IAP with SKPaymentQueue.default().restoreCompletedTransactions() and nothing work according to plan. In sandbox I get "There's no information available for In-App Purchases. Try again later. 21105" and in Prod just nothing happens. From what I can see that error in Sandbox is thrown with actual SKPaymentQueue.default().restoreCompletedTransactions() line and nothing is processed after that. I am sure everything is right, since I can make my purchase by hand and it works, I can also repurchase anything again with error, that I already have it and then item get activated, but Restore button is not working (restorePurchases()). I do have 38 IAP in this app, but I am not sure if that is related in any way, and they all are Non-Consumable. It is iMessage Extension that sells stickers. What is also strange, is that Apple did kick my app back because I used my Own Art without My own permission (that was halarious), but everything states, that with Non-Consumable must have Restore and Apple check for that, and in this case everything passed while it is not working.

I assumed when I created Non-Consumable IAP in itunesconnect it was automatically marked as product that can be restored and there is no extra steps needed. From what I can see in itunesconnect inside actual IAP data, only "Turn On Content Hosting" is optional, so what did I miss ?

1) I don't understand the Swift structure of switch/case/default/break - It is unusual how the case.restored code block is indented. Does it work/not work the same way if you switch the order of the blocks of case.purchased with case.restored?

2) A key question is whether StoreKit ever calls updatedTransactions with a state restored. In your case - are you or are you not executing the line:

I never get that far in sandbox, error I get is already in SKPaymentQueue.default().restoreCompletedTransactions().

As for SKPaymentQueue.default().add(self) I call it in getProducts() that is called from viewDidLoad() in main view, and that works fine, since I am getting all my IAP data and can actually buy anythging I want.

As for case, I am not sure either, but from what I have seen, even if I just do regular purchase I don't get any prints or anything else from restore part, so it might be good.

First - do you call getProducts() when all you want to do is restore? If not, then add SKPaymentQueue.default().add(self) to restorePurchases()

Second - add a print command to print out the value of transaction.transactionState in "for transaction in transactions {"

Third - switch the code block for case.purchased:do{...} with the code block for case.restored:do{...} and see if you can still make a purchase. That will prove that the code block for case.restored is correctly positioned. Something is wrong with the indentation - that must mean something about the Swift text editor or your structure of case.purchased:do{...} structure.

first - yes, getProduct() is always called on app start inside viewDidLoad() in the main view controller, so it is impossible to miss it. as an extra step in productsRequest() I have the haveData variable that is true only after I got data about all my IAP and then I display buy all button, and I do all tests after I see Buy All button

second - I never get that far in when I try to restore, I got an error message with code 21105 right after I press a button and I never get to paymentQueue(). From what I understand restore just kicks me out while saying - there is nothing to restore, go away.

third - technically only difference between .purchase and .restored is in this linedefaults.set(true, forKey: transaction.original!.payment.productIdentifier)or rather in restored it is transaction.original!.payment.productIdentifier while purchased it is transaction.payment.productIdentifier and rest is just print, log and popup, that never happens since it is never called.

Generally, I start to wonder logic in restore function. When I want to purchase something I need to pass specific IAP identifier to buy that (and that makes purchase functions quite generic, while restore function is a psychic - it finds old purchases on its own. Any chance I am missing something there and that why nothing works ?)

What is interesting is that I tested my IAP script in single view app and new iMessage app, and in a single view app all worked fine while in iMessage I got the same error again. The only question is - if it is official Apple bug, how come I see other apps that have restore button with animation; however, I have not tried to purchase anything there and restore afterwards

More Like This

Retrieving data ...

This site contains user submitted content, comments and opinions and is for informational purposes only. Apple disclaims any and all liability for the acts, omissions and conduct of any third parties in connection with or related to your use of the site. All postings and use of the content on this site are subject to the Apple Developer Forums Participation Agreement.