Base64EncodedStringWithOptions returns nil to get data

I want to validate my purchases in server side apps. So I am using the following code:

- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
{
    for (SKPaymentTransaction * transaction in transactions) {

        switch (transaction.transactionState)
        {
            case SKPaymentTransactionStatePurchased:
            {
                NSData *reciptData = [NSData dataWithContentsOfURL:[[NSBundle mainBundle] appStoreReceiptURL]];
                if(reciptData) {
                    NSDictionary *parameters = @{@"receipt_data" : [reciptData base64EncodedStringWithOptions:0]};//App crashes here -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[0]
                }
            }
                break;

            default:
                break;
        }
    };
}

      

The strangest thing is that the app crashes on one iPad with iOS 8.0.2 and doesn't crash on another version with the same iOS version.

The worst part is that I have no access to the device on which the application crashed.

From what I understand it - base64EncodedStringWithOptions:

returns nil

, but I don't know why.

Can anyone help me?

+3


source to share


1 answer


I've seen this empty problem getting before some form of app cracking program like "IAP Free" or "IAP Cracker" is launched on the devices, which implies that the device has been jailbroken and an in-app cracking tool has been installed. I would make sure that the device where the app crashes does not launch any kind of in-app app hacking tool. Another thing you can do is ignore a blank receipt, but not return an item to avoid a failure or return an item that is only available locally. It depends on how you want to react to someone hacking in-app purchases - sometimes it's good to pretend everything is running locally, but it limits your server's capabilities.



0


source







All Articles