OGeek|极客世界-中国程序员成长平台

标题: ios - 应用内购买 appStoreReceiptURL 为空 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-11 19:23
标题: ios - 应用内购买 appStoreReceiptURL 为空

2 个月前,我在我的应用程序中进行了自动更新购买,沙盒一切正常。但是现在我无法通过 NSBundle.mainBundle().appStoreReceiptURL 获得收据,这条路径不会退出。怎么会这样? 2 个月前(或更少)有收据。请帮帮我!这就是我获得收据的方式(swift 2)-

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 ""
}



Best Answer-推荐答案


根据文档,appStoreReceiptURL可能会或可能不会指向与收据一起归档。您可以使用 SKReceiptRefreshRequest 请求收据刷新.

关于ios - 应用内购买 appStoreReceiptURL 为空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47620812/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4