Search code examples
iosin-app-purchasestorekit

iOS app asks for password every time it is launched


I'm testing a new app on my device, and today, I started integrating the StoreKit for In-App Purchases.

The problem is that EVERY TIME I launch the app, it asks me for my sandbox account password. Here following, you'll find some details about the problem.

  1. The very first time I launched the app, everything worked as expected. No problems while completing the in-app purchase (with my sandbox user - let's call it testuser1@t.com -).
  2. Stopped the app, integrated a button "Restore purchases". Unfortunately, I forgot to add "finishTransaction" at completion (not sure if this could be the problem).
  3. From now on, every time I launch the app, it keeps asking me for testuser1@t.com's password.

StoreKit starts doing it's stuff in a view which is NOT the rootView, so I excluded that I'm casting something wrong programmatically...

So, what I did AFTER?

  1. Deleted app from device and reinstalled (after reboot)
  2. Deleted sandbox user (and created a new one - let's say testuser2@t.com -). I successfully used the NEW account in order to get a new IAP.
  3. Cleared settings on my device
  4. Deleted IAP from iTunes Connect

The problem is still there. Keep in mind that the password asked is for testuser1@t.com (the very first test account!)


Solution

  • Stopped the app, integrated a button "Restore purchases". Unfortunately, I forgot to add "finishTransaction" at completition (not sure if this could be the problem)

    That is indeed the problem!

    Store Kit will always ask you to re-authenticate if there are transactions left on the queue. To get rid of those transactions, just call:

    for transaction in SKPaymentQueue.defaultQueue().transactions {
        SKPaymentQueue.defaultQueue().finishTransaction(transaction)
    }