3

I have an app that has been available in the AppStore for a while now.
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.
I tried prying inside the receipt ([[NSBundle mainBundle] appStoreReceiptURL]) but I couldn't find anything informative.
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.
Is there a programatic way to tell if the app was purchased using the VPP?

Moshe Gottlieb
  • 3,963
  • 25
  • 41

1 Answers1

5

You were right to look inside the app receipt for VPP information, but you need to refresh it with the SKReceiptPropertyIsVolumePurchase flag set first:

self.refresh = [[SKReceiptRefreshRequest alloc] initWithReceiptProperties:@{SKReceiptPropertyIsVolumePurchase : @YES}];
self.refresh.delegate = self;
[self.refresh start];

You then get your receipt data in 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:

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. If you use Apple's receipt verifier, make sure to change the URL to https://buy.itunes.apple.com/verifyReceipt.

Rhythmic Fistman
  • 34,352
  • 5
  • 87
  • 159