Storekit 2

看了下Storekit 2 ,解决了1的很多问题,如Product的的信息扩充,测试状态下的退订状态。 而且使用上async,aawait的swift新特性,api,使用方法都很简单明了。就是对版本的要求现在来说还是有点高15.0

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

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

    switch result {
    case .success(let verification):
      let transaction = try checkVerified(verification)

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

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

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

你可能感兴趣的:(Storekit 2)