ios - 应用内购买 appStoreReceiptURL 为空
<p><p>2 个月前,我在我的应用程序中进行了自动更新购买,沙盒一切正常。但是现在我无法通过 NSBundle.mainBundle().appStoreReceiptURL 获得收据,这条路径不会退出。怎么会这样? 2 个月前(或更少)有收据。请帮帮我!这就是我获得收据的方式(swift 2)-</p>
<pre><code>static func receipt() -> String {
print("RECEPT URL", NSBundle.mainBundle().appStoreReceiptURL)
guard let receiptUrl = NSBundle.mainBundle().appStoreReceiptURL, let receiptPath = receiptUrl.path else { return "" }
let fileManager = NSFileManager.defaultManager()
if fileManager.fileExistsAtPath(receiptPath){
var receiptData: NSData?
do {
receiptData = try NSData(contentsOfURL: receiptUrl, options: NSDataReadingOptions.DataReadingMappedAlways)
}
catch {
print("ERROR: " )
}
//guard let receiptData = NSData(contentsOfURL: receiptUrl) else { return "" }
if let receiptString = receiptData?.base64EncodedStringWithOptions(NSDataBase64EncodingOptions(rawValue: 0)) {
print("REC", receipt, receiptString)
return receiptString
}
}
return ""
}
</code></pre></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>根据文档,<a href="https://developer.apple.com/documentation/foundation/bundle/1407276-appstorereceipturl" rel="noreferrer noopener nofollow">appStoreReceiptURL</a>可能会或可能不会指向与收据一起归档。您可以使用 <a href="https://developer.apple.com/documentation/storekit/skreceiptrefreshrequest" rel="noreferrer noopener nofollow">SKReceiptRefreshRequest</a> 请求收据刷新.</p></p>
<p style="font-size: 20px;">关于ios - 应用内购买 appStoreReceiptURL 为空,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/47620812/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/47620812/
</a>
</p>
页:
[1]