I am developing an iOS app in Swift 3 and trying to implement receipt validation following this tutorial: http://savvyapps.com/blog/how-setup-test-auto-renewable-subscriptio
I struggled my head with the same problem. The issue is that this line:
let receiptString = receiptData?.base64EncodedString(options: NSData.Base64EncodingOptions(rawValue: 0))
Returns an OPTIONAL and
jsonData = try JSONSerialization.data(withJSONObject: dict, options: .prettyPrinted)
cannot handle optionals. So to fix it, simply substitute the first line of code with this:
let receiptString:String = receiptData?.base64EncodedString(options: NSData.Base64EncodingOptions.lineLength64Characters) as String!
And everything will work like charm!