swift - 尝试进行收据验证时出现 ASDServerErrorDomain 错误
问题描述
我在应用商店中使用以下代码进行收据验证。如果收据不存在,则要求用户登录。这是我使用的类。
收据提取器
import Foundation
import StoreKit
class ReceiptFetcher : NSObject {
public var receiptRefreshRequest = SKReceiptRefreshRequest()
override init() {
super.init()
// receiptRefreshRequest.delegate = self
}
func fetchReceipt() {
let receiptPath = Bundle.main.appStoreReceiptURL?.path
do {
receiptRefreshRequest.start()
}
catch {
print("Could not check for receipt presence for some reason... \(error.localizedDescription)")
}
}
}
检查收据是否存在以及是否不尝试获取收据。对于当前场景,没有收据,调试器会命中 fetchreceipt 块。
if !FileManager.default.fileExists(atPath: receiptPath!){
receiptFetcher.receiptRefreshRequest.delegate=self
receiptFetcher.fetchReceipt();
}
else
{
receiptValidation()
}
func request(_ request: SKRequest, didFailWithError error: Error) {
print("Something went wrong: \(error.localizedDescription)")
DispatchQueue.main.async {
if let presenter = self.presenting as? ViewController {
presenter.showreceipterror()
self.dismissViewController(self)
NSApplication.shared.terminate(self)
}
}
这会导致以下错误。沙盒功能在允许传出连接的情况下打开。之前我能够成功以沙盒用户身份登录,我认为问题是在我从应用商店连接中删除用户后开始的。我已经清除了现有的收据通过重新构建。
0x600001c59ae0>: Finished refreshing receipt with error: Error Domain=ASDServerErrorDomain Code=500317 "Unhandled exception" UserInfo={NSLocalizedDescription=Unhandled exception, NSLocalizedFailureReason=An unknown error occurred}
解决方案
推荐阅读
- postgresql - 将 postgres 9.5 升级到 11
- react-native - 解析:使用 Google oAuth 初始注册后未检索到 sessionToken
- c - Fatfs 检测 SD 卡移除
- flutter - 如果在列中,Flutter Loader 动画不居中
- javascript - 无法将 shapefile 转换为 geojson
- ios - 如果 CollectionView 在 UIScrollView 内,如何设置 UICollectionView 项目大小?
- javascript - 如何解决 ngFor 用于 Angular 渲染的问题
- java - 为 findAllByTypeAndCreatedAtAfter() mongodb 方法添加最大大小限制和方向
- java - org.docx4j.openpackaging.exceptions.InvalidFormatException:错误 [Content_Types].xml
- jenkins - 如何在jenkins的JOB DSL中调用属性文件语法和定义