I followed this tutorial and everything works. But Xcode show me that transactionReceipt
is deprecated.
Now looking on google, I saw that you can change using this method:
[NSData dataWithContentOfURL:[[NSBundle MainBundle] appStoreReceiptURL]];
But if I make this change, in this way:
/* NSString *jsonObjectString = [self encodeBase64:(uint8_t *)transaction.transactionReceipt.bytes
length:transaction.transactionReceipt.length];
*/
NSData *data = [NSData dataWithContentsOfURL:[[NSBundle mainBundle] appStoreReceiptURL]];
NSString *jsonObjectString = [data base64EncodedString];
// Create the POST request payload.
NSString *payload = [NSString stringWithFormat:@"{\"receipt-data\" : \"%@\", \"password\" : \"%@\"}",
jsonObjectString, ITC_CONTENT_PROVIDER_SHARED_SECRET];
NSData *payloadData = [payload dataUsingEncoding:NSUTF8StringEncoding];
The validation always fails. Instead, if I leave transactionReceipt
all works properly.
What is the problem?
Note: Tested on iPhone 4 with iOS 7.1.