问题
transactionReceipt is deprecated. But I am not able to use,
[[NSBundle mainBundle] appStoreReceiptURL].
This is supposed to return a url to a receipt if there is one. But for me there isn't one, as this value is nil, and as far as I can tell it shouldn't be. I'm running on iOS 7 and have done a few in-app purchases (sandbox on the device).
Can anyone help .
回答1:
This will give you the receipt as the contents of the mainBundle's appStoreReceiptURL :-
[NSData dataWithContentsOfURL:[[NSBundle mainBundle] appStoreReceiptURL]];
Once you get that convert NSData to NSString.
For more details, see this :-
https://developer.apple.com/library/ios/releasenotes/General/ValidateAppStoreReceipt/Chapters/ValidateRemotely.html#//apple_ref/doc/uid/TP40010573-CH104-SW1
回答2:
try below:
NSData *dataReceipt = [NSData dataWithContentsOfURL:[[NSBundle mainBundle] appStoreReceiptURL]];
NSString *receipt = [dataReceipt base64EncodedStringWithOptions:0];
来源:https://stackoverflow.com/questions/27544351/how-to-use-appstorereceipturl