RevenueCat / purchases-ios

In-app purchases and subscriptions made easy. Support for iOS, watchOS, tvOS, macOS, and visionOS.
https://www.revenuecat.com/
MIT License
2.33k stars 315 forks source link

SyncPurchases does not migrate non-consumable purchases #2400

Closed ryanmeisters closed 1 year ago

ryanmeisters commented 1 year ago

Posted in community here but opening an issue because I'm pretty sure this is a bug.

Describe the bug My app previously had a single "pro" non-consumable purchase, and now I'm implementing subscriptions with revenue cat. Migrating the legacy non-consumable purchase doesn't work with the latest SDK version.

The problem is that, when doing the migration (as recommended in the docs), I hit this line of code, which short-circuits if there is no active subscription. Is it a bug that this code is ignoring non-consumables?

After more digging I found that this PR introduced the receipt.mostRecentActiveSubscription check. I downgraded my app to version 4.15.5 of the SDK (right before that PR was released) and the migration now works as expected.

  1. Environment
    1. Platform: iOS
    2. SDK version: 4.17.8
    3. StoreKit 2 (disabled with useStoreKit2IfEnabled(false)) (Y/N): Y
    4. OS version: 16.3.1
    5. Xcode version: 14.2
    6. How widespread is the issue. Percentage of devices affected. All
  2. Debug logs that reproduce the issue can privide if needed. (will take some setting up to get back to the state). Hopefully above description is clear
  3. Steps to reproduce, with a description of expected vs. actual behavior4.
    1. Other information (e.g. stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, etc.)

Additional context Add any other context about the problem here.

RCGitBot commented 1 year ago

👀 SDKONCALL-250 We've just linked this issue to our internal tracker and notified the team. Thank you for reporting, we're checking this out!

aboedo commented 1 year ago

@ryanmeisters could you provide us a bit more info regarding how you're making purchases and where you're seeing the non-consumable missing?

That line shouldn't be causing an issue: in theory, it should just check if you have an active subscription before posting a receipt to our backend, to send some extra information in those cases. Before that PR, the value for productData when posting to the backend was always nil when restoring, and afterwards, it should be nil if the user has no active subscriptions, and if they do, it should contain some extra information regarding the products they're subscribed to.

That being said, if you're actually experiencing an issue that goes away when rolling back to a previous SDK version, then we need to explore further.

Could you share debug logs and code snippets? Are you checking the information in the dashboard or through code?

ryanmeisters commented 1 year ago

Thanks for the reply. oh yeah, I see. That's just the completion handler and then backend.post(..) is still called. working on getting more info together

ryanmeisters commented 1 year ago

Well, shoot. Now I can't repro.

Tested migrating the legacy purchase to RC and also restoring legacy purchase to a different device with RC, and all seems to be working. I must be crazy 😞

aboedo commented 1 year ago

no worries, let me know if you run into this again!

ryanmeisters commented 1 year ago

will do, thanks. closing for now

github-actions[bot] commented 1 year ago

This issue has been automatically locked due to no recent activity after it was closed. Please open a new issue for related reports.