Titanium JIRA Archive
Appcelerator Modules (MOD)

[MOD-2368] iOS 11: Add App Store-initiated purchase support to Store Kit module

GitHub Issuen/a
TypeNew Feature
PriorityLow
StatusClosed
ResolutionFixed
Resolution Date2018-02-16T12:58:38.000+0000
Affected Version/sn/a
Fix Version/sTi.StoreKit 4.3.0
ComponentsStoreKit
Labelsstorekit
ReporterJacob Budin
AssigneeHans Knöchel
Created2017-10-09T17:22:09.000+0000
Updated2018-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).)

Comments

  1. Hans Knöchel 2017-10-11

    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 ?
  2. Jacob Budin 2017-10-12

    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 to true or false?).
  3. Hans Knöchel 2017-10-12

    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 property allowedStorePaymentProductIdentifiers that is an array of product-identifiers. Having those, we could compare them with the product proposed by the delegate and return true 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 return true. Quote from a dicussion in the native RMStore 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}
  4. Hans Knöchel 2017-10-12

    Here is my PR, try it out: https://github.com/appcelerator-modules/ti.storekit/pull/32
  5. Jacob Budin 2017-10-17

    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.
  6. Lorenzo Piccinini 2018-02-16

    Hello, beautiful upgrade! Are there any news about this new realease? Best regards
  7. Hans Knöchel 2018-02-16

    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.
  8. Lorenzo Piccinini 2018-02-16

    Wonderfull. I didn't seen it. Great job. Thanks
  9. Eric Merriman 2018-08-06

    Cleaning up older fixed issues. If this issue should not have been closed as fixed, please reopen.

JSON Source