[MOD-2368] iOS 11: Add App Store-initiated purchase support to Store Kit module
GitHub Issue | n/a |
---|---|
Type | New Feature |
Priority | Low |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2018-02-16T12:58:38.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Ti.StoreKit 4.3.0 |
Components | StoreKit |
Labels | storekit |
Reporter | Jacob Budin |
Assignee | Hans Knöchel |
Created | 2017-10-09T17:22:09.000+0000 |
Updated | 2018-08-06T17:49:30.000+0000 |
Description
iOS 11 introduced the ability [to promote in-app purchases in the App Store](https://developer.apple.com/app-store/promoting-in-app-purchases/). When the user clicks on one of these promoted items in the App Store, the app opens, and the user is prompted to buy the item. This new feature relies on the
SKPaymentTransactionObserver
instance method [paymentQueue:shouldAddStorePayment:forProduct:
](https://developer.apple.com/documentation/storekit/skpaymenttransactionobserver/2877502-paymentqueue?language=objc).
The [ti.storekit
](https://github.com/appcelerator-modules/ti.storekit) has not been updated since May 2017 and does not appear to support this feature. (See [TiStoreKitModule.m
](https://github.com/appcelerator-modules/ti.storekit/blob/ed85b9a731b40c3d0a538d97e6304ee75be69628/ios/Classes/TiStoreKitModule.m).)
Interesting change, we can add that to the module! Regarding "not updated since May", this should be fine, because that was when we added the latest iOS 10.3 specific API's. Ti.StoreKit is pretty complete, to keep it like that, the iOS 11 API's will follow. Regarding the API itself, the delegate expects a boolean indicating whether to open the app to do the purchase or not. How would you as a developer like to see this exposed to the module? Having a property like
allowAppStorePurchase
?Thanks for picking this up, Hans. I appreciate it. As I understand it, the boolean return value indicates whether to continue the transaction once in-app. So, for example, this would allow the app to cancel a transaction if the item wasn't available in the user's country or the item was a quantity-limited promotion that has "sold out." The app always opens.
allowAppStorePurchase
could work (would it default totrue
orfalse
?).The general problem is that we cannot really make this a configurable per-product property, because we don't have the relation between your local code and the requested products when being triggered from the app-store (because you cannot request the products and return then, it expects an immediate return-statements. So either make it a module-property, e.g.
TiStorekit.allowsAppStorePurchase = true
or find different solution. Looking into native storekit-wrappers, they are still having a similar problem, so I cannot find a finished implementation of the feature so far that would help getting inspired in the API design. *EDIT*: I might have an idea! We could have a propertyallowedStorePaymentProductIdentifiers
that is an array of product-identifiers. Having those, we could compare them with the product proposed by the delegate and returntrue
is it exists andƒalse
otherwise. Also, if the property is not set, all products are able to be downloaded / added to the payment queue, so it will returntrue
. Quote from a dicussion in the nativeRMStore
library: {quote} When you return true, the user will be shown that nice new in-app purchase payment sheet, so they can complete the transaction. And that's it. We're done. Time to ship it. Oh, all right. Well, what if the user is in the middle of onboarding? Or if they're creating an account? Or if they've already unlocked the item they're trying to buy? Well, in this case, you can hold onto the payment and return false. {quote}Here is my PR, try it out: https://github.com/appcelerator-modules/ti.storekit/pull/32
Hans, thanks so much. I had no idea this could and would be addressed so quickly. Appreciate it. I need to get additional approval before implementing this update, but I will reply back as soon as I can validate this update.
Hello, beautiful upgrade! Are there any news about this new realease? Best regards
Hey [~otto.pic], the new version was released a few weeks ago, see [Ti.StoreKit 4.3.0](https://github.com/appcelerator-modules/ti.storekit/releases/tag/v4.3.0). We just forgot to resolve the ticket, have fun with it! See the new "allowedStorePaymentProductIdentifiers" property in the docs on GitHub for details.
Wonderfull. I didn't seen it. Great job. Thanks
Cleaning up older fixed issues. If this issue should not have been closed as fixed, please reopen.