How to use appStoreReceiptURL

痴心易碎 提交于 2019-12-06 17:02:34

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!