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