I have two places when I initiate the same UIView with possibility to buy an InApp purchasable product. 1. End of user onboarding 2. Standard place in menu
From the 1st one the payment is initiated I get to the updatedTransactions with SKPaymentTransactionStatePurchasing:
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
{
DLog(@"updatedTransactions");
for (SKPaymentTransaction *transaction in transactions)
{
switch (transaction.transactionState)
{
case SKPaymentTransactionStatePurchased:
// I get here when the controller is initiated from menu, not from my user onboarding
break;
case SKPaymentTransactionStateFailed:
[self failedTransaction:transaction];
break;
case SKPaymentTransactionStateRestored:
[self restoreTransaction:transaction];
break;
case SKPaymentTransactionStatePurchasing:
// I get here
break;
default:
break;
}
}
}
But then this method is never called when user finish the transaction.
When I initiate the same controller from the menu everything works fine.
Any ideas?
Thank you
Probably you are setting the wrong transaction observer (or not setting it) in one of the two mentioned controllers.
In order to receive notifications when a transaction is updated, you have to add the observer this way:
[[SKPaymentQueue defaultQueue] addTransactionObserver:something];
where something
can be self
(if your paymentQueue:updatedTransactions:
method is on self
) or another object.
If you post the relevant code of the two controllers (controller names and calls to the addTransactionObserver:
method mentioned above plus a bit of context) I can give you more informations, but until then I can make some assumption.
Let's assume that you have two controllers:
UserOnboardingController
UpgradeController
You say that in the UpgradeController
it works correctly, this is probably because when the controller is loaded (in viewDidLoad:
for example) there is a call to
[[SKPaymentQueue defaultQueue] addTransactionObserver:self];
and the paymentQueue:updatedTransactions:
is one of the methods of UpgradeController
.
However, when you are on UserOnboardingController
, you don't call or pass the wrong observer to addTransactionObserver:
method.
If this is the situation, you should:
AppDelegate
or another specific singleton class)If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With