Storekit 2 some question

Hello,The Storekit 2 is pretty good, i want to Use it in my app right now,but i found some question? 1、unfinished transation never Automatic trigger on any where,such as when I start up again, how can i fetch the unfinished transations on some way? 2、i call transaction.finish(),but, when i user Transaction.unfinished to fetch all unfinished transations, the transaction i just finished, alway be funded 3、how can i verified jws myself, not call the autoVafified api you provide,can you has some demo?

Could you show the code where you experience problem ?

hi ,the detail i put it to answer

  • All Question is on IAP Sandbox Test
  • Question one: unfinished transation never Automatic trigger ,such as when I start up again,i can not fetch the unfinished transations in the Transaction.updates?
  /// - Returns: Task
  func listenForTransactions() -> Task<Void, Error> {
    return Task.detached {
      //Iterate through any transactions which didn't come from a direct call to `purchase()`.
      for await result in Transaction.updates {
        do {
          let transaction = try self.checkVerified(result)

          //Deliver content to the user.
          await self.updatePurchasedIdentifiers(transaction)

          //Always finish a transaction.
          await transaction.finish()
        } catch {
          //StoreKit has a receipt it can read but it failed verification. Don't deliver content to the user.
          print("AAAA=Transaction failed verification")
        }
      }
    }
  }
  • Question Two: i call transaction.finish() after purchae success,but, when i user Transaction.unfinished to fetch all unfinished transations, the transaction still exist. the count of unfinished is growing
  func restore() async {
    try? await AppStore.sync()
     
    await self.restoreProducts()
  }
   
  func restoreProducts() async {
    var count:Int = 0
    for await result in Transaction.unfinished {
      //Don't operate on this transaction if it's not verified.
      if case .verified(let transaction) = result {
        //Check the `productType` of the transaction and get the corresponding product from the store.
        switch transaction.productType {
        case .nonConsumable:break
        case .autoRenewable:
          count += 1
        case .nonRenewable:break
        default:
          //This type of product isn't displayed in this view.
          break
        }
      }
    }
     
    print("unfinished = \(count)")
  }
  • Question There:how can i verified jws myself, not call the autoVafified api you provide, can you has some demo?
  • thanks
Storekit 2 some question
 
 
Q