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

Safeguard against nil productIdentifiers or payments #297

Merged
merged 1 commit into from
Aug 4, 2020

Conversation

vegaro
Copy link
Contributor

@vegaro vegaro commented Jul 28, 2020

We were assuming transaction.payment.productIdentifier to not be nil in some places in RCPurchases.

This will most likely fix #279

@vegaro vegaro requested a review from aboedo July 28, 2020 20:53
@@ -953,8 +953,11 @@ - (void)handleReceiptPostWithTransaction:(SKPaymentTransaction *)transaction
[self markAttributesAsSyncedIfNeeded:subscriberAttributes appUserID:self.appUserID error:error];

RCPurchaseCompletedBlock completion = nil;
NSString *productIdentifier = transaction.payment.productIdentifier;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's add nullable since we're going to check for nullabiilty.
we should also maybe add a log entry, in case a future dev looks at the docs and (reasonably) assumes that this should never be nil.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could have a method that unwraps the whole thing and RCLogs if we're using it in a couple of places.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added it in d735da0, I doubted about making an extension function on SKTransaction, what do you think?

Comment on lines 1181 to 1182
- (nullable NSString *)productIdentifierFrom:(SKPaymentTransaction *)transaction
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: the { should go at the end,
- (nullable NSString *)productIdentifierFrom:(SKPaymentTransaction *)transaction {

@aboedo
Copy link
Member

aboedo commented Aug 4, 2020

It looks like #303 had some tests that could fail depending on the speed of the machine.
I'll push a fix for it, I'll let you know when to rebase

@aboedo
Copy link
Member

aboedo commented Aug 4, 2020

#304 should fix the tests

@vegaro vegaro force-pushed the cesardelavega/ch698/crash-when-loading-products branch from 8207f32 to a3c8694 Compare August 4, 2020 20:50
@vegaro vegaro merged commit e899020 into develop Aug 4, 2020
@vegaro vegaro deleted the cesardelavega/ch698/crash-when-loading-products branch August 4, 2020 21:20
@vegaro vegaro mentioned this pull request Aug 4, 2020
@aboedo aboedo mentioned this pull request Aug 27, 2020
@aboedo aboedo mentioned this pull request Sep 10, 2020
@aboedo aboedo mentioned this pull request Jul 13, 2021
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

Successfully merging this pull request may close these issues.

Crash when loading products
2 participants