Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
AlbertRenshaw opened this issue Mar 24, 2018 · 0 comments
Open

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

AlbertRenshaw opened this issue Mar 24, 2018 · 0 comments

Comments

@AlbertRenshaw
Copy link

AlbertRenshaw commented Mar 24, 2018

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)");
    }

}];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant