最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

ios - How to track consumable In-App Purchase transaction of StoreKit 2 with SwiftUI? - Stack Overflow

programmeradmin5浏览0评论

I have scenario same as this sample project of StoreKit 2 in SwiftUI.

I am facing issue while transaction will be interrupted (like change payment method, incoming call, app close, battery died, anything...)

While buying fuel, it will available for all cars. I want to track fuel for particular car. How can I track transaction(interrupted)?

func purchase(_ product: Product) async throws -> Transaction? {
    // Begin purchasing the `Product` the user selects.
    let result = try await product.purchase()

    switch result {
    case .success(let verification):
        // Check whether the transaction is verified. If it isn't,
        // this function rethrows the verification error.
        let transaction = try checkVerified(verification)

        // The transaction is verified. Deliver content to the user.
        await updateCustomerProductStatus()

        // Always finish a transaction.
        await transaction.finish()

        return transaction
    case .userCancelled, .pending:
        return nil
    default:
        return nil
    }
}

Steps to understand the issue:

  1. Go to "Shop"
  2. Buy "Race Car" & "Off-road vehicle"
  3. Click on "Race Car" to go in the detail page
  4. Try to buying "fuel87" for "Race Car" (this scenario might be not reproducible in sandbox account)

Now, I can see "fuel87" for both car. (I know, fuel is fuel for all the car. BUT in my case I have to track "fuel" for selected car)

How can I achieve that?

发布评论

评论列表(0)

  1. 暂无评论