I want to publish an iOS app that has an auto renewing subscription. While there is a ton of information regarding this, much is outdated so I will state what I have accomplished so far.
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() } }
However, I cannot figure out how to decode the receipt so then I can determine the expiration date and other verification steps to ensure it is a valid receipt.
I have to say it is very frustrating that something very essential and useful to developers has to be so difficult to follow and locate. Any help is much appreciated and hopefully will be useful to many others.