gpt4 book ai didi

找不到 iOS 收据

转载 作者:行者123 更新时间:2023-11-28 19:31:54 28 4
gpt4 key购买 nike

我正在 Swift 3.0 应用程序中实现应用程序内购买,因此我需要获取应用程序收据以根据 iTunes 商店对其进行验证。这是我获得收据的方式:

func getReceipt() -> Data? {
if Bundle.main.appStoreReceiptURL != nil {
print("app receipt: \(Bundle.main.appStoreReceiptURL)")
do {
let receiptData = try Data(contentsOf: Bundle.main.appStoreReceiptURL!)
print(receiptData)
return receiptData
} catch {
print("error converting receipt to Data: \(error.localizedDescription)")
}
}
return nil
}

我的收据 URL 的控制台输出是:

app receipt: Optional(file:///Users/dustinspengler/Library/Developer/XCPGDevices/433E8E8F-B781-4ADC-A92D-5CABC28E94D6/data/Containers/Data/Application/C25BE9B6-FB64-4D49-9CF2-9DA371060A7B/StoreKit/receipt)

然后无法将收据转换为 Data 并且 catch 语句打印:

error converting receipt to Data: The file “receipt” couldn’t be opened because there is no such file.

我在 Playground 、模拟器和真实设备上运行时得到完全相同的输出,所以考虑到用户尚未进行应用内购买,这是否意味着该应用不存在收据? 在阅读 Apple 的 documentation 时我得到的印象是它们总是被创建,而不管之前的购买。

最佳答案

此答案基于应用程序在您的本地计算机上运行的上下文。如果该应用在应用商店上架,即使它是免费的,您下载该应用时也会收到一张收据。

由@Paulw11 回答:

There is no receipt until the user makes a purchase. For an app downloaded from the App Store (even a free one). This is a purchase, so there will be a receipt. For a debug build from Xcode there is no receipt until an in-app purchase is made.

关于找不到 iOS 收据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43146453/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com