Skip to main content
Question

customerInfoStream


Forum|alt.badge.img+1

Hello!

Could anyone please explain to me how does restoring purchases for anonymous user IDs work? I’m using

for await customerInfo in Purchases.shared.customerInfoStream {
  let hasNoActiveEntitlements = customerInfo.entitlements.active.isEmpty
  Superwall.shared.subscriptionStatus = hasNoActiveEntitlements ? .inactive : .active
}

to sync subscription status between RevenueCat and Superwall, but it works inconsistently, sometimes it never gets inside the for loop and sometimes it works without issues. Maybe I don’t get the idea and this code needs to be called after the app is in some specific state?

2 replies

Ryan Glanz
RevenueCat Staff
Forum|alt.badge.img+8
  • RevenueCat Staff
  • 364 replies
  • October 12, 2023

Hi,

Restoring purchases depends on what setting you have, but here’s our default: https://www.revenuecat.com/docs/restoring-purchases#transfer-to-new-app-user-id

 

It sounds like that code isn’t being executed because the customerInfo object isn’t changing. Have you set up the Purchases Delegate?


Forum|alt.badge.img+1
  • Author
  • New Member
  • 1 reply
  • October 12, 2023

Yep, it seems to be working correctly when I’m running the example project with my API key. So, I guess, users have to trigger the ‘restore purchases’ logic whenever it’s a re-install. In this case it works as expected. Thanks!


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings