Question

customerInfoStream

  • 10 October 2023
  • 2 replies
  • 49 views

Badge

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

Userlevel 3
Badge +8

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?

Badge

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