我在生产中拥有的功能齐全的代码在visionOS上不起作用,这是怎么回事?我得到了这个错误
‘Purchase(Options:)’在visionOS中不可用:使用@Environment(.Purchase)获取要调用的Purche eAction值.如果你的应用程序使用UIKit,使用购买(confirmIn:Options:).
如何更改代码以满足visionos的要求?
func purchase(_ product: Product) async throws -> Transaction? {
let result = try await product.purchase() //TEMPORARY JAN-23
switch result {
case .success(let verification):
// Successful purchase
//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()
更新:我意识到我需要做ios17的购买方式,但他们的ios16购买方式不能与ios17方式共存!!怎么了!!
我不能这么做
struct PaymentViewVoice: View {
@Environment(\.presentationMode) var presentationMode
@EnvironmentObject private var store: Store
@Environment(\.purchase) var purchase // For iOS 17 payments
错误:‘购买’仅在iOS 17.0或更新版本中可用
and 我不能这么做
struct PaymentViewVoice: View {
@Environment(\.presentationMode) var presentationMode
@EnvironmentObject private var store: Store //for ios6 payments
@available(iOS 17.0, *)
@Environment(\.purchase) var purchase // For iOS 17 payments
错误:存储的属性不能用‘@Available’标记为可能不可用