I check receipts in applications with the following code:
- (void) completeTransaction:(SKPaymentTransaction*) transaction
{
NSData* receipt = nil;
NSBundle* mainBundle = [NSBundle mainBundle];
if ([mainBundle respondsToSelector:@selector(appStoreReceiptURL)]) {
NSURL* appStoreReceiptURL = [mainBundle appStoreReceiptURL];
receipt = [NSData dataWithContentsOfURL:appStoreReceiptURL];
}
if (!receipt) {
receipt = [transaction transactionReceipt];
}
[self verifyReceipt:receipt forTransaction:transaction];
}
On an iOS 6 device, execution stops on the line NSURL* appStoreReceiptURL = [mainBundle appStoreReceiptURL];, and the console spits:
-[NSBundle appStoreReceiptURL]: unrecognized selector sent to instance 0x208492d0
Am I missing something? Shouldn't I -respondsToSelector:take care of this? Should I go back to checking the OS version directly?
source
share