admin管理员组

文章数量:1391987

I have a purchase manager class and an entitlement manager class. Everything is working great, but this code is not working.

init(entitlementManager: EntitlementManager) {
    self.entitlementManager = entitlementManager
    super.init()
    self.updates = observeTransactionUpdates()
    SKPaymentQueue.default().add(self)
}
extension SubscriptionsManager: SKPaymentTransactionObserver {
    
    func paymentQueue(_ queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction]) {
    }
    
    func paymentQueue(_ queue: SKPaymentQueue, shouldAddStorePayment payment: SKPayment, for product: SKProduct) -> Bool {
        return true
    }
}

The Xcode warning message is:

SKPaymentQueue was deprecated in iOS 18.0: No longer supported
SKPaymentTransaction was deprecated in iOS 18.0: Use PurchaseResult from Product.purchase(confirmIn:options:)

I want to support in-app purchases from the App Store. How should I do this?

I have a purchase manager class and an entitlement manager class. Everything is working great, but this code is not working.

init(entitlementManager: EntitlementManager) {
    self.entitlementManager = entitlementManager
    super.init()
    self.updates = observeTransactionUpdates()
    SKPaymentQueue.default().add(self)
}
extension SubscriptionsManager: SKPaymentTransactionObserver {
    
    func paymentQueue(_ queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction]) {
    }
    
    func paymentQueue(_ queue: SKPaymentQueue, shouldAddStorePayment payment: SKPayment, for product: SKProduct) -> Bool {
        return true
    }
}

The Xcode warning message is:

SKPaymentQueue was deprecated in iOS 18.0: No longer supported
SKPaymentTransaction was deprecated in iOS 18.0: Use PurchaseResult from Product.purchase(confirmIn:options:)

I want to support in-app purchases from the App Store. How should I do this?

Share Improve this question edited Mar 26 at 5:25 HangarRash 15.1k5 gold badges20 silver badges55 bronze badges asked Mar 15 at 10:00 kjfhkekjfhke 11 bronze badge 1
  • Use StoreKit 2 functions – Paulw11 Commented Mar 15 at 10:06
Add a comment  | 

1 Answer 1

Reset to default 0

StoreKit 2 is the new standard and you can implement a store with all the basic functionality

import SwiftUI
import StoreKit

struct BirdFoodShop: View {
  @Query var birdFood: [BirdFood]
 
  var body: some View {
    StoreView(ids: birdFood.productIDs) 
  }
  
}


//Or a produxt button

ProductView(id: product.id)

Meet StoreKit 2 can walk you through all the basics and Meet StoreKit for Swiftui will walk you through the newest views.

Here is some sample code

https://developer.apple/documentation/StoreKit/implementing-a-store-in-your-app-using-the-storekit-api

https://developer.apple/documentation/SwiftUI/Backyard-birds-sample

本文标签: