0

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?

1
  • Use StoreKit 2 functions Commented Mar 15 at 10:06

1 Answer 1

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.com/documentation/StoreKit/implementing-a-store-in-your-app-using-the-storekit-api

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.