I'm newbie with in-app purchases and SwiftyStoreKit.
I made an in-app purchases in my app and sent it for moderation.
My application moderator rejected and wrote the reason:
We found that your in-app purchase products exhibited one or more bugs when reviewed on iPhone and iPad running iOS 14.1 on Wi-Fi.
Specifically, your app’s In-App Purchases do not show the app’s price. Also, upon further review, we found that your app does not allow users to purchase the In-App Purchases.
Next Steps
When validating receipts on your server, your server needs to be able to handle a production-signed app getting its receipts from Apple’s test environment. The recommended approach is for your production server to always validate receipts against the production App Store first. If validation fails with the error code "Sandbox receipt used in production," you should validate against the test environment instead.
The price was not displayed probably because the application received the answer code: "skerrordomain code=0" or something like that. Or because the Apple server returned 0 products.
That is, when ViewController starts, app request the price of the products from the Apple server and then write it down to the buttons.
I don't know exactly what the problem is, because on my local device purchases work with a Sandbox user. In Simulator I get an error: "skerrordomain code=0".
Here is a code sample:
enum RegisteredPurchase: String {
case item1 = "com.app.appname.item1"
case item2 = "com.app.appname.item2"
case item3 = "com.app.appname.item3"
}
purchases: [RegisteredPurchase]
var productList: Set<String> = []
for purchase in purchases {
productList.insert(purchase.rawValue)
}
SwiftyStoreKit.retrieveProductsInfo(productList) { result in
var products: Dictionary<RegisteredPurchase, String> = [:]
for product in result.retrievedProducts {
products[RegisteredPurchase(rawValue: product.productIdentifier)!] = product.localizedPrice
}
if (result.error == nil) {
self.setupPrice(products)
}
}
In the result I get retrievedProducts. On the local device all 3 products come, in Simulator I get 0 and the error.
Fixed by removing all products and creating new ones.