Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone inApp Purchase Queue won't clear out

I have InApp purchasing setup in my app. I am having some weird behavior though. Each time I start up the app I call

[[SKPaymentQueue defaultQueue] addTransactionObserver:self];

to setup the initial observer. However this immediately triggers

- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions

with a full array of every transaction. I have tried just calling

[[SKPaymentQueue defaultQueue] finishTransaction: transaction];

on each of these transaction then restarting the app again but paymentQueue is still trigger as soon as I call addTransactionObserver. My main goal right now is just to flush the transaction queue and start clean. I don't know how I got into this state, nor how to get out of it.

like image 722
TurqMage Avatar asked May 19 '11 19:05

TurqMage


People also ask

Why is my in app purchase not working?

Restart the device Tap Power off or Restart (depending on your device this text may be different). If needed, hold down the power button again to turn the device back on. Wait for the device to start back up. Re-open the app or game and check if the in-app purchase has been delivered.

Why does my iPhone say your purchase could not be completed?

Your Apple ID may be linked with too many credit cards. Your credit card may be blocked. You're trying to buy something which is not allowed by Apple in your country. You know how some apps or content may not be available or might be banned from certain countries?

Why can't I purchase in app purchases Apple?

Make sure that you're signed in with the same Apple ID that you used to make the purchase. Make sure that in-app purchases are allowed on your device. Restart your device: Restart your iPhone.

How do I disable in app purchases?

Prevent Accidental In-App Purchases on AndroidIn the Store's top-right corner, tap your profile icon. In the profile menu, tap “Settings.” On the “Settings” page, select “Authentication.” In the expanded “Authentication” menu, tap “Require Authentication for Purchases.”


2 Answers

From SKPaymentTransactionObserver:PaymentQueue.. call:

SKPaymentQueue.default().finishTransaction(transaction)

Note that you can not call for all types. Calling finishTransaction for .purchasing will crash with error. So a for through all transactions is not a complete solution.

When you Call finishTransaction for .purchasing:

 *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Cannot finish a purchasing transaction'
like image 91
Andres Canella Avatar answered Sep 19 '22 11:09

Andres Canella


Make sure you have implemented this method:

-(void)paymentQueue:(SKPaymentQueue *)queue removedTransactions:(NSArray *)transactions;
like image 45
JessicaM Avatar answered Sep 16 '22 11:09

JessicaM