Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SKPaymentQueue addTransactionObserver asking for App Store password on startup after in-app purchase

My app is using in-app purchases, and most of my users can purchase just fine without any problems. For these folks, my app downloads the content after the purchase succeeds and they are happy.

However, for a growing number of my users, once they complete a successful in-app purchase they are being asked for their App Store password every time the app starts up after that. I believe this is happening on the call to:

[[SKPaymentQueue defaultQueue] addTransactionObserver:observer];

which I am calling on startup in accordance with step 6 in Apple's in-app purchase guide:

  • archived guide: https://web.archive.org/web/20130515222703/https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/StoreKitGuide/AddingaStoretoYourApplication/AddingaStoretoYourApplication.html
  • actual guide: https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/StoreKitGuide/Chapters/DeliverProduct.html#//apple_ref/doc/uid/TP40008267-CH5-SW4

My guess is that, for some reason, Apple's in-app purchase servers aren't registering that the transaction finished successfully - even though I call

[[SKPaymentQueue defaultQueue] finishTransaction:transaction];

when the transaction is completed and my content has been successfully downloaded.

2 questions:

  1. Is anyone else seeing this?

  2. Does anyone have a suggested fix?

BOUNTY EDIT:

Its a transaction which was made with a different Apple-ID. Thats why it cannot be finished unless you type in the right credentials into the dialog. The Question should be either:

  1. How can I prevent such dead transactions (transaction has not been finished, user has no network, meanwhile changes App-ID)?
  2. How can you prune the SkPaymentQueue?
like image 569
montuno Avatar asked Feb 14 '11 03:02

montuno


3 Answers

I had the same problem.make sure that you call

[[SKPaymentQueue defaultQueue] finishTransaction:transaction]; 

for all three states of the transactions: SKPaymentTransactionStatePurchased, SKPaymentTransactionStateRestored, SKPaymentTransactionStateFailed.

like image 70
Ilker Baltaci Avatar answered Nov 16 '22 13:11

Ilker Baltaci


I had the same problem of having the login prompt coming up at the call:

[[SKPaymentQueue defaultQueue] addTransactionObserver:observer];

It would also come up every now and then even when I wasn't using my app (on the home screen or in other apps), which was really annoying. Looking around, there seem to be so many suggested answers to this issue but I finally found a solution from a combination of what I've gathered.

Note: Before step 1, I had removed the test sandbox account in iTunes Connect. I'm not sure if that would affect the solution.

To solve the problem this is what I did:

  1. Run your app from Xcode.
  2. Wait for the prompt to come up. Type in the password for the account it wants and tap OK.
  3. Press the Home button on the device.
  4. Kill the app from Xcode.
  5. Delete the app from the device.
  6. Log out of iTunes & App Store in the Settings app.
  7. Turn off the device and then turn it back on.
  8. Purchase something from the App Store. When it prompts you, log in with a production Apple ID account. (I'm assuming you should be able to just log in with a production account in iTunes & App Store under the Settings app but this is how I did it).
  9. Go back to Xcode and run your app again. (This should be a new install, as you deleted the app before.)
  10. Wait for the login prompt to come up.
  11. Tap Cancel. A dialog saying "Sign In Required. Tap Continue and sign in to check for downloads. [Environment: Sandbox]" should come up. This was a key difference from before. I never had this dialog come up when I pressed Cancel when it was asking me for the password.
  12. Tap Continue.
  13. Enter the password for the account.

That's it. From then on the login prompt stopped coming up whenever I ran my app and also stopped coming up at random times.

Hope this helps!

like image 8
Aero Avatar answered Nov 16 '22 14:11

Aero


DO NOT DELETE THE ANSWER HERE. It was this particular Stackoverflow question that misled me and messed me up for days.

I'm putting this here because there are a lot of really bad answers that provide WRONG information on how to resolve the problem.

DO NOT:

  • Delete the sandbox test user. This makes it impossible to resolve the problem and you will have to contact Apple developer support to resolve manually.
  • If you delete the sandbox test user, when you are subsequently repeatedly prompted to log in as that user and complete the transaction, you can't, hence the name Endless Loop problem. Nor will you be able to add the deleted test user again; the developer portal says the user id has already been used.
  • Delete the App or re-install iOS or any other such nonsense. It has no effect, doesn't solve the problem and wastes a lot of time.

DO:

  • Call Finish for ALL transactions.
  • If one is interrupted for some reason, simply complete on a subsequent run of the App. The app will be repeatedly sent the payment queue notice until you call finish on it:

[[SKPaymentQueue defaultQueue] finishTransaction:transaction];

That's it, Finish all transactions! Else you will be sent to the hell of the Endless Loop of sign in requests every single time your App launches on that device.

like image 8
Cliff Ribaudo Avatar answered Nov 16 '22 15:11

Cliff Ribaudo