[英]How can I tell if an app was purchased using Apple's volume purchase program for education?
I have an app that has been available in the AppStore for a while now. 我有一个已在AppStore中使用了一段时间的应用程序。
I can see from the iTunes reports that it's been purchased using Apple's volume purchase program , which is great, however - I would like to know if a certain device is running a volume purchased app or a standard AppStore app. 我从iTunes的报告中可以看到,它是使用Apple的批量购买程序购买的 ,这很棒,但是-我想知道某个设备是在运行批量购买的应用程序还是标准的AppStore应用程序。
I tried prying inside the receipt ( [[NSBundle mainBundle] appStoreReceiptURL]
) but I couldn't find anything informative. 我尝试在收据(
[[NSBundle mainBundle] appStoreReceiptURL]
)中进行[[NSBundle mainBundle] appStoreReceiptURL]
但找不到任何有用的信息。
Creating a different bundle ID for this purpose is not an option, and kind of misses the idea of the VPP so, please - don't offer it. 为此目的,创建另一个捆绑包ID是不可行的,并且会遗漏VPP的想法,请-不要提供它。
Is there a programatic way to tell if the app was purchased using the VPP? 是否可以通过编程方式得知该应用是否是使用VPP购买的?
You were right to look inside the app receipt for VPP information, but you need to refresh it with the SKReceiptPropertyIsVolumePurchase
flag set first: 您可以在应用收据中查看VPP信息,但是您需要首先设置
SKReceiptPropertyIsVolumePurchase
标志来刷新它:
self.refresh = [[SKReceiptRefreshRequest alloc] initWithReceiptProperties:@{SKReceiptPropertyIsVolumePurchase : @YES}];
self.refresh.delegate = self;
[self.refresh start];
You then get your receipt data in requestDidFinish:
然后,您可以在
requestDidFinish:
获取收据数据requestDidFinish:
- (void)requestDidFinish:(SKRequest *)request {
NSURL *receiptURL = [[NSBundle mainBundle] appStoreReceiptURL];
NSData *receipt = [NSData dataWithContentsOfURL:receiptURL];
// decode receipt and examine vpp fields here
}
There are many ways to decode an apple receipt, I find the easiest way is to use Apple's receipt verifier, so I moved the receipt data to a file ( receipt-data.der
) on my computer: 解码Apple收据的方法有很多 ,我发现最简单的方法是使用Apple的收据验证程序,因此我将收据数据移到了计算机上的文件(
receipt-data.der
)中:
curl -d "{ \"receipt-data\" : \"$(base64 receipt-data.der)\" }" https://sandbox.itunes.apple.com/verifyReceipt
This showed some interesting new fields: 这显示了一些有趣的新领域:
"organization_display_name": "ACME Bad VPPReceipt Inc."
"receipt_type": "ProductionVPPSandbox"
"expiration_date": "2015-12-10 00:44:22 Etc/GMT"
This is in the sandbox, so results will change when you move to production, but this should be enough to figure out if a given device is vpp or not. 这是在沙箱中,因此结果将在您进入生产环境时发生变化,但这足以确定给定设备是否为vpp。 If you use Apple's receipt verifier, make sure to change the URL to
https://buy.itunes.apple.com/verifyReceipt
. 如果您使用Apple的收据验证程序,请确保将URL更改为
https://buy.itunes.apple.com/verifyReceipt
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.