Using unfinished transactions to share consumables cross device in iOS?

TL;DR Can you postpone the finishTransaction call on a consumable in iOS to mimic androids consumeAsync?


In Android one can purchase an item it will end up in a list managed by the billing api. And can be accessed via [queryPurchaseHistoryAsync][1].


An item can then be consumed later. The purchase and the consumption are two separate things so.


An account is optional in our app and we use the described functionality in android to keep track of the items a user has purchased / but not yet consumed also when one lost his/her device.


The docs are not clear on the [SKPaymentQueue][2] regarding multi-device synchronization.


"The contents of the queue are persistent between launches of your app."


But in practice, it seems to be exchanged between devices.


While different [sources][3] suggest you have to take care of managing the state of consumables for your self.


I was wondering if one can use the SKPaymentQueue as a single point of truth by keeping the consumable [SKPaymentTransaction][4] in the [purchased][5] state. I would therefore not call the [finishTransaction][6] before the item has actually consumed.


In theory, the transaction should stay in the SKPaymentQueue and should be transferred to all devices logged in with the same AppStore account.


As soon as the transaction is finished on one of the devices it should get removed from the queue and again the information should be spread to all devices.


I couldn't find this approach somewhere and I would like to know if I miss something important here.


[1]: https://developer.android.com/reference/com/android/billingclient/api/BillingClient.html#queryPurchaseHistoryAsync%28java.lang.String,%20com.android.billingclient.api.PurchaseHistoryResponseListener%29

[2]: https://developer.apple.com/documentation/storekit/skpaymentqueue

[3]: https://stackoverflow.com/questions/22599763/how-to-consume-a-purchased-item-with-in-app-purchase-on-ios

[4]: https://developer.apple.com/documentation/storekit/skpaymenttransaction

[5]: https://developer.apple.com/documentation/storekit/skpaymenttransactionstate/purchased

[6]: https://developer.apple.com/documentation/storekit/skpaymentqueue/1506003-finishtransaction

TMI.

A consumable IAP purchase results in a call to updatedTransactions on that device only. The receipt on each device is different. So there is no way a consumable purchase on one device can be seen in the receipt on a different device.


Use the user's iCloud key-value file to communicate among the user's devices.

Accepted Answer

Are you checking transaction pending status whenever your app starts?


Seen the discussion in this SO thread? https://stackoverflow.com/questions/47405906/in-app-product-shows-pending-even-after-deduction-of-money


>would like to know if I miss something important here.


In those cases, be sure to check the IAP FAQ - examples payment queue and finished transactions: https://developer.apple.com/library/archive/technotes/tn2413/_index.html - "


And while the FAQ may or may not address your specific question, it might help to delineate between iOS and android in the future.


Good luck.

Using unfinished transactions to share consumables cross device in iOS?
 
 
Q