简体   繁体   中英

In-app purchases trouble with SwiftyStoreKit and AppStore Connect moderator

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.

通过删除所有产品并创建新产品来修复。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM