Skip to content

Instantly share code, notes, and snippets.

@a2
Created November 24, 2013 14:14
Show Gist options
  • Save a2/7627720 to your computer and use it in GitHub Desktop.
Save a2/7627720 to your computer and use it in GitHub Desktop.
SKHandleInvalidReceiptRequest & SKTerminateForInvalidReceipt
@import StoreKit;
@interface SKHandleInvalidReceiptRequest : SKRequest
- (void)_sendXPCMessage;
@end
extern void SKTerminateForInvalidReceipt(void);
#import "StoreKit.h"
@interface SKRequest ()
- (void)_startWithMessage:(xpc_object_t)message replyBlock:(dispatch_block_t)replyBlock;
- (void)_shutdownRequest;
@end
@implementation SKHandleInvalidReceiptRequest
- (void)_sendXPCMessage
{
xpc_object_t message = xpc_dictionary_create(NULL, NULL, 0);
xpc_dictionary_set_int64(message, "0", 0x271c);
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
[self _startWithMessage:message replyBlock:^{
dispatch_semaphore_signal(semaphore);
}];
dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
dispatch_release(semaphore);
xpc_release(dict);
[self _shutdownRequest];
}
@end
void SKTerminateForInvalidReceipt(void) {
SKHandleInvalidReceiptRequest *request = [[SKHandleInvalidReceiptRequest alloc] init];
[request start];
[request release];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment