Open aryamobomo opened 9 years ago
Got the same crash in my app. It seems to be in the line 330 of MKSoreKit.m:
[MKStoreKit startValidatingAppStoreReceiptWithCompletionHandler:]_block_invoke (MKStoreKit.m:330)
It seems it is actually the same issue as #221
I get nil in this line and it crashes on the next line:
[self.purchaseRecord setObject:originalAppVersion forKey:kOriginalAppVersionKey];
I also experience this crash in a released version, but it seems to affect 100% only Jailbroken devices....
Please check out Whether if shared secret is correct?
I'm getting crashes too, modded code to make sure originalAppVersion in non nil, but haven't tested yet.
No, unfortunately just checking originalAppVersion for nil doesn't stop the crashes, as I'm still getting them. The crash happens before originalAppVersion is used. The problem is that jsonResponse[@"receipt"] is returning an NSNull object, so I think you just need to check for NSNull before those lines:
if (jsonResponse[@"receipt"] != [NSNull null]) { NSString *originalAppVersion = jsonResponse[@"receipt"][@"original_application_version"]; if (originalAppVersion != nil) { [self.purchaseRecord setObject:originalAppVersion forKey:kOriginalAppVersionKey]; [self savePurchaseRecord]; } }
I haven't tested this yet though.
Anyone have any success yet? Strange to see so many crashes here daily
Yes, my fix seems to be working so far. It's been on the app store for a few weeks now, with no new crashes.
Awesome!
It looks like jsonResponse[@"receipt"][@"in_app"] is also crashing when the receipt is NSNull, so that needs to be checked too. Also I'm calling completionHandler(nil, nil) in cases where I'm finding these null cases.
I'll create a pull request in a month or two once I'm sure I've fixed all the crashes. In the meantime, here is my current version of MKStoreKit.m:
Thanks @dwj.
Is MugunthKumar still active to fix this on the main code ? It's a frequent bug that is open for months now.
My fix seems to be working well -- no crashes in the last month. I've just created a pull request. I also tidied up the code a little and fixed a few bugs with #includes which were causing it to fail to compile.
Thanks for your help dwj
NSInvalidArgumentExceptionMKStoreKit -[NSNull objectForKeyedSubscript:]: unrecognized selector sent to instance 0x19932eba0
MKStoreKit crashes on validating receipts in the method startValidatingAppStoreReceiptWithCompletionHandler..
Crash is happening in the line NSArray *inAppReceipts = jsonResponse[@"receipt"][@"in_app"];