我有一个应用程序已经在 AppStore 中可用了一段时间。
我可以从 iTunes 报告中看到它是使用 Apple's volume purchase program 购买的,这很好,但是 - 我想知道某个设备运行的是批量购买的应用程序还是标准的 AppStore 应用程序。
我尝试在收据内窥探 ([[NSBundle mainBundle] appStoreReceiptURL]
) 但我找不到任何信息。
为此目的创建不同的 bundle ID 不是一种选择,并且有点错过了 VPP 的想法,所以请不要提供它。
是否有一种程序化的方式来判断该应用程序是否是使用 VPP 购买的?
最佳答案
您在应用程序收据中查看 VPP 信息是正确的,但您需要首先设置 SKReceiptPropertyIsVolumePurchase
标志来刷新它:
self.refresh = [[SKReceiptRefreshRequest alloc] initWithReceiptProperties:@{SKReceiptPropertyIsVolumePurchase : @YES}];
self.refresh.delegate = self;
[self.refresh start];
然后您在 requestDidFinish:
中获取收据数据
- (void)requestDidFinish:(SKRequest *)request {
NSURL *receiptURL = [[NSBundle mainBundle] appStoreReceiptURL];
NSData *receipt = [NSData dataWithContentsOfURL:receiptURL];
// decode receipt and examine vpp fields here
}
有many ways要解码苹果收据,我发现最简单的方法是使用 Apple 的收据验证器,所以我将收据数据移动到我计算机上的文件 (receipt-data.der
) 中:
curl -d "{ \"receipt-data\" : \"$(base64 receipt-data.der)\" }" https://sandbox.itunes.apple.com/verifyReceipt
这显示了一些有趣的新字段:
"organization_display_name": "ACME Bad VPPReceipt Inc."
"receipt_type": "ProductionVPPSandbox"
"expiration_date": "2015-12-10 00:44:22 Etc/GMT"
这是在沙盒中,因此当您进入生产环境时结果会发生变化,但这应该足以确定给定设备是否为 vpp。如果您使用 Apple 的收据验证程序,请确保将 URL 更改为 https://buy.itunes.apple.com/verifyReceipt
。
关于ios - 如何判断应用程序是否是使用 Apple 的教育批量购买计划购买的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33614194/