j3k0 / cordova-plugin-purchase

In-App Purchase for Cordova on iOS, Android and Windows
https://purchase.cordova.fovea.cc
1.3k stars 535 forks source link

[IOS] Any plans about StoreKit 2? #1204

Open thekhegay opened 3 years ago

thekhegay commented 3 years ago

Hello, j3k0!

Do you have any plans about StoreKit 2?

StoreKit 2 has a lot of breaking changes out of box: For example, new Transactions looks great and simple (there is no .purchased, .failed, .deferred, .restored)

func purchase(_ product: Product) async throws -> Transaction? {
    let result = try await product.purchase()

    switch result {
    case .success(let verification):
        // handle success
        ...
        return result

    case .userCancelled, .pending:
        // handle if needed

    default: break
}

Also, we can pass some custom data with transactions and store one:

let result = try await product.purchase(options::[.appAccountToken(yourAppToken))])

And: restore() changed to .sync() and works automatically.

But! StoreKit2 will be available only iOS 15+

j3k0 commented 3 years ago

Yes, StoreKit 2 fixes many issues of the StoreKit API. It'll probably require a fresh implementation, but it is definitely something we will support. I hope we can provide StoreKit 2 support with a transparent failover to the legacy API. The plugin's API probably won't change as most of the new features are things that already exist on Android. I can't provide a date at the moment.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

andypapas commented 2 years ago

Do you have any updates on the plan for this? Would be great to be able to store the account UUID in the transactions.

jfbloom22 commented 1 year ago

Is storekit 2 ready for us to start testing in v13? https://github.com/j3k0/cordova-plugin-purchase/issues/1204

j3k0 commented 1 year ago

I looked into it a couple of month ago, the issue is that StoreKit 2 is only available for Swift (as opposed to Objective C). Integrating Swift into a Cordova plugin is a mess. It requires manual editing of the project's XCode project to generate a bridging header. In many cases, this is just not be possible at all. Until cordova improves on that front, StoreKit 2 cannot be integrated.

An option I see is to integrate it as a separate "payment adapter" plugin (like the Braintree adapter), so those who want to get into this trouble can chose to. But it looks like most users of this plugin are now using it through an another platform's compatibility layer (like capacitor). Then it might not be worth the trouble, because as far as I understood, the manual XCode project editing hack does not work with those platforms.

jfbloom22 commented 1 year ago

Very interesting. I am working on integrating this plugin in my capacitor project right now. Sounds like StoreKit 2 is something that a native capacitor version of this plugin will be able to support more easily.