As mentioned in apple guidelines:
Listing 1-5 Parse the payload using asn1c
#include "Payload.h" / This header file is generated by asn1c. */
/ The receipt payload and its size. */
void *pld = NULL;
size_t pld_sz;
/ Variables used to parse the payload. Both data types are declared in Payload.h. */
Payload_t *payload = NULL;
asn_dec_rval_t rval;
/ ... Load the payload from the receipt file into pld and set pld_sz to the payload size ... */
/ Parse the buffer using the decoder function generated by asn1c. The payload variable will contain the receipt attributes. */
rval = asn_DEF_Payload.ber_decoder(NULL, &asn_DEF_Payload, (void **)&payload, pld, pld_sz, 0);As it says on line 11, Load the payload from the receipt file into pld, i tried using following code:
const char * path = [[[[[NSBundle mainBundle] appStoreReceiptURL] path] stringByStandardizingPath] fileSystemRepresentation];
FILE *fp = fopen(path, "rb");
size_t sizeOfFile;
sizeOfFile = ftell(fp);
void *pld = (char *)malloc(sizeof(char)*sizeOfFile);
fread(pld,1,sizeOfFile, fp);
size_t pld_sz;But still asn_DEF_Payload.ber_decoder fails, i also tried to load pld using following code:
NSData *receipt = [NSData dataWithContentsOfURL:[[NSBundle mainBundle] appStoreReceiptURL]];
void * pld = (void *)[transactionReceiptData bytes];
size_t pld_sz = (size_t)[transactionReceiptData length];Still no success, can anyone please help how to load payload from receipt file into pld.