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

Fix: sharedPurchases nullability #508

Merged
merged 3 commits into from
May 25, 2021
Merged

Conversation

aboedo
Copy link
Member

@aboedo aboedo commented May 21, 2021

As mentioned in #490, the value of sharedPurchases can be nil, but it's marked as non-nullable.

This can lead to some awkward behavior, particularly in Swift, where the compiler will assume that the value is not nil and will not let you check against it.

To solve this, this PR does 2 things:

  • adds an assert when calling sharedPurchases, since calls to it will no-op, which is unexpected behavior the vast majority of the time.
  • adds a new property, isConfigured, that you can use to know whether it's safe to call sharedPurchases. I added this so that if someone is indiscriminately calling a method and relying on no-ops, they can use the new property to keep their code compatible with this behavior. However, this should only ever be used in very specific circumstances.

@aboedo aboedo requested a review from a team May 21, 2021 21:38
@aboedo aboedo self-assigned this May 21, 2021
@note True if the SDK has been configured, false otherwise. This property should only be used in special circumstances. If the shared instance has not been configured,
calls made to it will raise an exception.
*/
@property (class, nonatomic, readonly) BOOL isConfigured;
Copy link
Member Author

Choose a reason for hiding this comment

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

This doesn't exist in Android, and I'm not 100% sure it's needed.

However, we are changing the behavior of the SDK, so maybe it's helpful for some folks if they're migrating behaviors.

Note that the previous behavior is the no-op, which no one should really have been relying on.

Copy link
Contributor

Choose a reason for hiding this comment

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

sounds good

@aboedo aboedo merged commit d55e6e5 into develop May 25, 2021
@aboedo aboedo deleted the fix/sharedInstance_nullability branch May 25, 2021 20:17
@aboedo aboedo mentioned this pull request May 27, 2021
@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.

2 participants