iosswiftapp-storestorekit

Issue getting the current App Store‘s region information


I am trying to use the StoreKit API to get the current App Store‘s region. It can work,but not always right.

if #available(iOS 13, *){
    let queue = SKPaymentQueue.default()
    if let storefront = queue.storefront {
        let countryCode = storefront.countryCode
        let identifier = storefront.identifier
        print("Country Code: \(countryCode)")
        print("Identifier: \(identifier)")
    } else {
        print("Failed to get storefront information")
    }
}

My current account is a China account. The country code and identifier return "CHN" and "143465". It looks right. Then I just change the App Store account (not iCloud) and the new logged-in account is an America account. But the country code and identifier still return "CHN" and "143465". It is incorrect. How can I fix this issue?


Solution

  • Please check if there is any developer account logged in at Settings > App Store > SANDBOX ACCOUNT, this is a separate entity that is referred by StoreKit when app is using sandbox purchases.