Solved

iOS Bug: RCPurchases offeringsWithCompletionBlock offerings and error are both nil

  • 14 September 2021
  • 3 replies
  • 85 views

Badge +4

We noticed some unusual behavior. This seems to happen when there is no clear error and we are unsure if this was intended or not. Consider the following code:

 

[[RCPurchases sharedPurchases] offeringsWithCompletionBlock:^(RCOfferings* offerings, NSError* error)
{
if (offerings.current)
{
...
}
else if (error)
{
...
}
else
{
// this branch actually gets executed!
...
}
}];

Both offerings.current and error are nil in some cases. Usually it has something to do with running on iOS simulator or when the IAPs aren’t setup properly (which can be seen in the logs), but the implication in the call is that error will never be nil. Luckily we were able to identify this issue quickly and patch our code with a workaround, but maybe the SDK team might want to revise that behavior.

 

We haven’t tested  if other calls have the same issue or if other platform SDKs have it.

icon

Best answer by Anonymous 24 September 2021, 23:09

View original

3 replies

Ohhh no.
Yeah, that’s weird. Thank you for reporting!

We recently migrated all our objc to swift, and we definitely found areas where we didn’t handle every possible case- so that’s to say, I think this is fixed, at least in the beta.

If you’re feeling adventurous, you could give our new release a try:  https://github.com/RevenueCat/purchases-ios/blob/main/docs/V4_API_Updates.md
We recently updated it to `4.0.0-beta.3` 

Userlevel 4
Badge +8

Hi!! Thanks for reporting!!

We’ve confirmed the issue and made a fix, it’s currently waiting for review and we’ll get it out the door soon.

https://github.com/RevenueCat/purchases-ios/pull/879/

 

Userlevel 4
Badge +8

Quick update here:

The fix has been deployed in release 3.12.6, and also to our v4 beta. If you’re using our beta builds, you can point to the `main` branch of `purchases-ios` to get it.

Now, if no offerings can be created from the data in the backend (either because there are no products in App Store Connect, or you’re running in the simulator, or well, there are no offerings in the backend), the method will return an error with a helpful message, including links to documentation to fix the issues.

Thanks once more for reporting this! And please let us know if you run into any other unexpected behavior in the future!!

Reply