菜鸟教程小白 发表于 2022-12-11 19:23:51

ios - 应用内购买 appStoreReceiptURL 为空


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

<pre><code>static func receipt() -&gt; String {
    print(&#34;RECEPT URL&#34;, NSBundle.mainBundle().appStoreReceiptURL)

    guard let receiptUrl = NSBundle.mainBundle().appStoreReceiptURL, let receiptPath = receiptUrl.path else { return &#34;&#34; }
    let fileManager = NSFileManager.defaultManager()
    if fileManager.fileExistsAtPath(receiptPath){
      var receiptData: NSData?
      do {
            receiptData = try NSData(contentsOfURL: receiptUrl, options: NSDataReadingOptions.DataReadingMappedAlways)
      }
      catch {
            print(&#34;ERROR: &#34; )
      }

      //guard let receiptData = NSData(contentsOfURL: receiptUrl) else { return &#34;&#34; }
      if let receiptString = receiptData?.base64EncodedStringWithOptions(NSDataBase64EncodingOptions(rawValue: 0)) {
            print(&#34;REC&#34;, receipt, receiptString)

            return receiptString
      }
    }
    return &#34;&#34;
}
</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]
查看完整版本: ios - 应用内购买 appStoreReceiptURL 为空