I am trying to integrate RevenueCat into my Flutter app. Regarding Authentication I have the following setup:
I have a LocalAuthId, which is created when the app is installed. I think this is comparable to the AnonymousId from RevenueCat, but I’d rather be in full control and also I’m using this ID in other parts of the app.
I also have the option for users to either log in to an existing account, or create a new account. In both cases the user would then also have a ServerAuthId, which is connected with their database account in supabase.
The expected behavior is the following:
Upon installing the app, the user is not signed in to the supabase server, and therefor only has a LocalAuthId for now. I call PurchasesConfiguration(<key>)..appUserID = myLocalAuthId; to configure RevenueCat on the device. The user should be able to purchase a subscription, which would then be linked to this device.
Then, if the user decides to create an account, I believe that the purchase should be transferred to the newly created ServerAuthId, which would be the new ID of the Customer.
At this point the device is “logged in”, in which case I would call PurchasesConfiguration(<key>)..appUserID = serverAuthId;
In case the user downloads the app on a new device and logs into their account, they would also gain access to the Purchases.
But now I am confused about the following cases:
What would / should happen if a user makes a Purchase before logging in, and then logs into an account which already has an Active Subscription?
What would happen given the following flow:
Download → Purchase Anonymously → Create Account (Purchase is linked to ServerAuthId instead of Local AuthId) → User Logs Out
In my estimation my app would then try to fetch the purchases with the LocalAuthId, which should turn up empty. But if the user hits restore, wouldn’t the restore give them access again since? In this case they could sign up to a new account and keep doing that to create unlimited accounts while only paying one subscription. Or would, in the case of the user hitting restore, the Customer Id in RevenueCat be reset to the LocalAuthId again and the ServerAuthId would loose access?
I hope I am explaining myself well, this is all very new to me but I would love to incorporate RevenueCat in my app.
My app layout is simple with the option of using and purchasing anonymously as well as logging in, and I’m trying to figure out which SDK calls I should tie to which actions and events in my app, specifically concerning log-in, sign-up, log-out and restore.
1000x thanks for anybody taking the time to read through all of that,
Jacob
Setting up RevenueCat with and without Authenticated Users
![Strength In Numbers Badge](https://uploads-us-west-2.insided.com/revenuecat-en/attachment/ad9785ad-84a4-4bde-98db-d0de530785fc_thumb.png)
I can’t delete the post so I’ll just add this here:
I think I found a working solution for now. I realize that my post is pretty badly explained so there’s no need in answering. Thanks anyways.
Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.