I'm trying to implement auto-renewable subscriptions. I have added a SKPaymentQueue transaction observer in the app delegate and I remove it as soon as the app terminates. Everything works but the problem is, on the next app launch, when the transaction observer is added it triggers updatedTransactions function and it gets straight to the Purchased state, for all the previous purchased transactions. After the user buys the subscription I call [[SKPaymentQueue defaultQueue] finishTransaction:transaction] in the SKPaymentTransactionStatePurchased state. However this does not work. What could I do in order to prevent this? Thanks in advance.
Asked
Active
Viewed 192 times
0
-
I'm calling `[[SKPaymentQueue defaultQueue] finishTransaction:transaction]` for every `SKPaymentTransactionStatePurchased`, `SKPaymentTransactionStateRestored` and `SKPaymentTransactionStateFailed`. Hope this helps. – demosten Nov 12 '20 at 13:13
-
Unfortunately I'm already doing that. Thanks for the tip anyway! – reapf Nov 12 '20 at 13:22
-
Try this. Remove the app from the device and remove the sandbox user from App Store settings. Install again and do a subscription, when asked for credentials use `different` sandbox user. It might work as expected. – demosten Nov 12 '20 at 13:31
-
I just tried but the issue is still there. However I noticed that it doesn't happen at every app launch, it looks like it is random. I read on Apple's documentation that on observer initialisation it will look for unfinished transactions and complete them. Could it be related to that? – reapf Nov 12 '20 at 14:07
-
The main issue here is Apple sandbox's ... magic. It is basically unreliable. It is hard to be sure is it you, doing something wrong or just the backend not working properly in this hour. I did the following. I took 1 or 2 open source libraries for IAP and when in doubt, used their code as a pool of ideas, am I doing the right things in the right order. – demosten Nov 12 '20 at 14:19
-
Well, I followed all Apple's guidelines on how to implement iaps and subscription, I'm sure I'm doing everything correctly. Also I noticed that quitting the app through the multitasking menu correctly removes the observer, while stopping the app in Xcode doesn't. I confide in that. – reapf Nov 12 '20 at 15:31