Hello! I am architecting the backend for a mobile application and despite reading through a lot of documentation posts, I feel I’m going in circles trying to grasp some subtle points and would love to get some answers before committing a lot of development.
So I understand the basics of user IDs and anonymous user ids. Our app will ONLY allow users to login (and get an explicit User ID recorded in our database) AFTER a purchase.
No problem: users get an anonymous ID, they sign in and we assign them a new, unique App User ID, which we record, and use login() to associate with their RC account.
The question happens when the same user logs into a fresh device (or reinstalls). They get a new anonymous ID upon starting up, but then what happens when they “Restore purchases”?
My hope is that we would be able to get access to the previously assigned App User ID. However, the documentation for Restoring Purchases mentions:
If an anonymous ID restores and the owner of the receipt is an identified App User ID, we will resort to the specified restore behavior and transfer the receipt to the anonymous user.
I’m reading that to mean that the owner would now be this “new anonymous id”, but what about the user id we created and assigned earlier? Is there a way we can get the App User ID from a fresh install → Restore Purchases, even if when first starting up a user will be assigned an anonymous ID?
If not, that means that at that point, when the user needs to log in to our system, we don’t "know” they are a prior user and have no way to link their purchase to the ID we previously assigned, causing us to potentially create a duplicate account for the same user (e.g. if they use a different login method to our database, etc.).
I’m probably missing something very simple but any help would be greatly appreciated! Thank you!