Skip to main content
Question

customerInfoStream

  • October 10, 2023
  • 2 replies
  • 394 views

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?

This post has been closed for comments

2 replies

Ryan Glanz
RevenueCat Staff
Forum|alt.badge.img+8
  • RevenueCat Staff
  • 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
  • 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!