Skip to content

App Crash if Apple's Receipt Servers return nil #51

@Apps4LifeLLC

Description

@Apps4LifeLLC

When validating receipt, Apple's response can be nil, which causes the app to crash when it tries to convert nil to JSON via NSDictionary* rec = [IAPShare toJSON:response];

I propose a modification simply in the read-me doc's example code, to now be as follows:

[[IAPShare sharedHelper].iap checkReceipt:[NSData dataWithContentsOfURL:[[NSBundle mainBundle] appStoreReceiptURL]] AndSharedSecret:@"your sharesecret" onCompletion:^(NSString *response, NSError *error) {

    if (response)
    {

        //Convert JSON String to NSDictionary
        NSDictionary* rec = [IAPShare toJSON:response];

        if([rec[@"status"] integerValue]==0)
        {
    
          [[IAPShare sharedHelper].iap provideContentWithTransaction:trans];
            NSLog(@"SUCCESS %@",response);
            NSLog(@"Purchases %@",[IAPShare sharedHelper].iap.purchasedProducts);
        }
        else {
            NSLog(@"Fail");
        }

    }
    else {
        NSLog(@"Fail (Apple server malfunction or connection interruption)");
    }

}];

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions