How to save a UserID without the Login in Kotlin

115 Views Asked by At

I am pretty new to Kotlin. I was trying to implement the purchases through RevenueCat in my app but I need to have a User ID in order to identify the user and associate their purchases.

Typically you would have a Login, and use for example the Firebase ID, so that the User ID always stays the same for that specific user.

But I don't have a Login (since it wouldn't really make sense for my app), so I need to generate a User ID and save it somehow, so that it won't change even if the user deletes the app and reinstalls it, or if they change the device.

In my iOS app I simply used the Key-Storage from iCloud so that the User ID is saved and will always stay the same, even if the app is deleted or the user has a new device because the User ID is associated with their Apple ID basically.

I can't find a way to properly do it also in Android without a Login.

Does anyone have a suggestion about that? Is it even possible?

1

There are 1 best solutions below

1
On

In android you can use Google account with firebase to achieve the same. Even though user change their device, you can identify with their Google account. You can even use Firebase for iOS too, which was useful to users, as they can have their same account in both iOS and Android.

In android by the combination of Google's Firebase auth and Sharedpreferences can save the user's preference, which was similar to iOS's userdefault.