我想发布一个具有自动续订订阅的iOS应用程序。虽然关于此方面有很多信息,但大多数都已过时,因此我将说明我已经完成的工作。
I am working in Swift 2.0, so any objective C code will not help me.
I will not be using my own server to communicate with Apple to verify the receipt, so I believe I either need to have the app communicate with Apple servers directly or I can parse the receipt locally on the device.
I have been able to locate a receipt on the device (not sure if there are multiple ones) using the following code
func checkForReceipt() { let receiptUrl = NSBundle.mainBundle().appStoreReceiptURL let fileExists = NSFileManager.defaultManager().fileExistsAtPath(receiptUrl!.path!) if fileExists { let receiptData = NSData(contentsOfURL: receiptUrl!) //Now what do I do to decode the data and validate the receipt } else{ requestReceipt() } }
然而,我无法弄清楚如何解码收据,以确定到期日期和其他验证步骤,以确保它是有效的收据。
我不得不说,这个对开发人员非常重要且有用的东西竟然如此难以遵循和定位,真的很令人沮丧。任何帮助都将不胜感激,并希望能对许多其他人有所帮助。