TLDR; Only configure with a known ID, and never call logout to prevent anonymous IDs.
Why does the SDK use Anonymous App User IDs?
Anonymous App User IDs are generated when the SDK is configured without a provided known ID. App User IDs are used to make sure the subscription that RevenueCat is tracking gets associated with the correct user. Anonymous App User IDs are always prefixed with $RCAnonymousID:
which can be useful for working with anonymous users on your server. Many apps use a combination of anonymous App User IDs and their own known App User IDs which provides flexibility in their user purchase flows. However, some applications are intended only to be used while using a known App User ID, without anonymous users at all. In that case, unintentionally creating Anonymous App User IDs can cause unwanted issues for developers and end users. To never see anonymous IDs, you need to make sure to do the following.
Only Configure the SDK with a known user ID
The most frequent place that anonymous App User IDs are created is when the SDK is first configured. Calling configure on the SDK without providing a known user ID will cause the SDK to generate an Anonymous ID for the current user. To avoid anonymous IDs, you will need to identify the user’s ID, before configuring the SDK. Many applications use their own login system often shared on multiple platforms, to identify users and provide their unique App User IDs.
Do not Logout the User
After the user is logged in with a known ID, they may want to switch accounts on your application - logout and then login with a different known ID. However, calling logout in the SDK will result in an anonymous App User ID being created. Simply do not logout the SDK. In the case of switching accounts, call login when the user logs in to the different account with their new App User ID.
Let us know if you have any questions in the comments below.