user3385829
user3385829

Reputation: 137

Is it possible to log a device ID as a unique user ID in Firebase?

This is for a messaging web app. Is there a universal ID assigned to each device that can be pulled through a web browser, which is brand/operating software agnostic?

I'd like to grab a unique ID related to a user that visits my website and save it to my database as that unique user for that device. Is this possible?

My goal is to assign users based on them accessing through a given device rather than signing up with a username. Theoretically, everyone is a user as soon as they access the site.

It's a messaging app run through the mobile web browser only but I don't want to hassle users through a sign up or login process. The device accessing the site would prompt me to send them data based on their user profile.

Upvotes: 1

Views: 2018

Answers (1)

Luka
Luka

Reputation: 166

signInAnonymously seems appropriate for that.

If there is already an anonymous user signed in, that user will be returned; otherwise, a new anonymous user identity will be created and returned. https://firebase.google.com/docs/reference/js/firebase.auth.Auth#signinanonymously

Due to the unauthenticated nature of this kind of user, they are not transferrable across devices. https://developers.google.com/android/reference/com/google/firebase/auth/FirebaseAuth#public-taskauthresult-signinanonymously

A user's UID never changes. So after you sign in a user anonymously, the UID will remain the same until you call signInAnonymously again or until you call signout. https://stackoverflow.com/a/47856853/11136299

Upvotes: 1

Related Questions