I run the build on the Real Device: iphone 12, IOS 16.1.1, Project (Xcode 13).
I am using a simple config class for SK1.
I get the error "<SKProduct: 0x281b68500>: Skipping product "Monthly_test_9.99_id" because no price was available" ❌
Running on Emulator (iPhone 8, iOS 16.1) runs well! ✅
My manager: StoreKit1
class StoreKitManager: NSObject {
static let shared = StoreKitManager()
private let productIDs: Set<String> = [
"Monthly_test_9.99_id"
]
private var productRequest: SKProductsRequest?
private func requestProducts() {
productRequest?.cancel()
let productRequest = SKProductsRequest(productIdentifiers: productIDs)
productRequest.delegate = self
productRequest.start()
self.productRequest = productRequest
}
func initialize() {
requestProducts()
}
}
extension StoreKitManager: SKProductsRequestDelegate {
func productsRequest(_ request: SKProductsRequest, didReceive response: SKProductsResponse) {
guard !response.products.isEmpty else { print("Found 0 products"); return }
for product in response.products {
print("Found product: \(product.productIdentifier)")
print(product.isFamilyShareable)
print(product.localizedTitle)
print(product.price.decimalValue)
}
}
func request(_ request: SKRequest, didFailWithError error: Error) {
print("Failed to load products with error:\n \(error)")
}
}
I also wrote a manager for StoreKit2 + UIKit. It runs on my device is well ✅ (iPhone 12).
This is a partial solution to the problem. Since my application build is for ios 14, but (StoreKit2 is available from ios 15).
My manager: StoreKit2 - I hope someone will help.
@available(iOS 15.0, *)
struct StoreKit2Manager {
static let shared = StoreKit2Manager()
private let productIDs: Set<String> = [
"Month_9.99",
"Year_29.99"
]
func requestProducts(completion: @escaping ([Product]) -> Void) async {
// MARK: SK2
do {
let arrProducts = try await Product.products(for: productIDs)
completion(arrProducts)
} catch {
print("Error requestProducts")
}
}
}
Use:
func requestSK() {
Task {
if #available(iOS 15.0, *) {
await StoreKit2Manager.shared.requestProducts { arr in
for item in arr {
print(item.id)
print(item.price)
print(item.displayName)
}
}
}
}
}
✅ Solution! On device.
- For testing on the device, you need to remove the storekit configuration file in scheme build ! (after runs buid, answer should come)
- You must have a public certificate uploaded to RavenueCat and a Sandbox account created.
- Log in to Sandbox after trying to purchase a product