I want to know in iOS in-app purchase flow, what's the best way to handle interrupted transactions?
Let's see the following interrupted puchasing scenario:
1.Make purchase with AppStore
SKPaymentQueue.defaultQueue().addPayment(payment)
2.On response is received
public func paymentQueue(queue: SKPaymentQueue, updatedTransactions)
We'll try to persist the purchase in our own server
Try to communicate with our server to persist the purchase
The communication failed due to unstable network
Therefore, we do not call the finishTransaction
The user closes the app, and relaunch
We should now try to resume step 3 before we can finish the transaction
However, I really don't know how to handle the following situation...
>>Problem:
It seems that if there exists an unfinished transaction, a login dialog pops up every time my app is launched even if I didn't register the observer:
SKPaymentQueue.defaultQueue().addTransactionObserver(self)
I've done the following experiment:
Make a purchase of nonrenewable-subscription Do not finish the transaction on purpose
Relaunch the app. The login dialog pops up as expected
Modify the code to remove the observer in my
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool
Relaunch the app. The login dialog still pops up -> not good
>>What I want:
I want to control when the login dialog pops up...as well as when the paymentQueue get called so our app can do things that actually finish the transaction (persist the purchase data to our server or download the content purchased by the user)
The reason is that we want the user to understand the login dialog is for us to finish the transaction for him, and we'll try to persist the transaction in our own server.
Therefore I need a way to trigger the login dialog as well as the following transaction update callback
public func paymentQueue(queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction])
Pls help! Thank you so much for reading this