看起来苹果本月正在进行任何类型的更新......最近我的应用程序被拒绝并显示此消息
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.
我的应用程序之前已获得批准...这是我正在使用的代码
//Sandbox URL
//let url = URL(string: "https://sandbox.itunes.apple.com/verifyReceipt")!
let url = URL(string: "https://buy.itunes.apple.com/verifyReceipt")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.httpBody = bodyData
let task = URLSession.shared.dataTask(with: request) { (responseData, response, error) in
if let error = error {
completion(.failure(.other(error)))
} else if let responseData = responseData {
let json = try! JSONSerialization.jsonObject(with: responseData, options: []) as! Dictionary<String, Any>
//print(json)
let session = Session(receiptData: data, parsedReceipt: json)
self.sessions[session.id] = session
let result = (sessionId: session.id, currentSubscription: session.currentSubscription)
completion(.success(result))
}
}
task.resume()
}
最佳答案
您不必使用服务器。如果需要,您可以在客户端上验证它。或者,如果您愿意,您可以完全放弃任何验证(不推荐)。
您收到的拒绝很可能是因为这一次,他们使用了测试环境来验证 IAP。
他们的documentation州
If you are doing receipt validation, be sure to verify your receipt with the production URL (https://buy.itunes.apple.com/verifyReceipt) first. This applies even in the case where your app is used in the sandbox environment. App Review will review the production version of your app in the sandbox. When your app processes the receipt, it must be capable of detecting the 21007 receipt status code and sending the receipt to the sandbox receipt validation server (https://sandbox.itunes.apple.com/verifyReceipt). Once your app is approved and running in the production environment, sending the receipt to the production server first is the correct action.
请注意,他们没有指定收据验证在哪里完成。
您的代码缺少的是沙箱的回退。这就是为什么他们这次拒绝了你。
关于ios - 验证收据 iOS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54917474/