I have a class events, and I want a user to be able to store their favourite events and access these from their device. The problem with this is that I'd prefer not to have to log in - basically I want to save the data based on the device being used. Could I use the device token to do this, or is this unreliable? Does anyone know any other ways to do this?
-
what about device mac address ! – code4rox Feb 20 '19 at 12:47
-
How would I get this? – minikate Feb 20 '19 at 12:58
-
Try this one https://stackoverflow.com/questions/11705906/programmatically-getting-the-mac-of-an-android-device – code4rox Feb 20 '19 at 12:59
-
I think getting MAC addresses has become redundant - this seems to be the case in the answers on that link – minikate Feb 20 '19 at 13:18
-
Do you guys know what a MAC address is? Anyway, don't use it to uniquely identify a person. – Zun Feb 20 '19 at 14:15
3 Answers
basically I want to save the data based on the device being used.
It's not such a good option since the user can change the device at any given time.
Could I use the device token to do this, or is this unreliable?
In Firebase, there two different tokens:
A FCM Token/Instance ID token that identifies an installation of a specific application on a specific user device. It doesn't identify in any way a particular user.
An Auth ID token identifies a specific user of a specific application. It doesn't identify in any way a particular device.
The two tokens are quite different and serve different purposes. Please see the official documentation for Android regarding on how to retrieve ID tokens on clients.
Unfortunately, none of the two tokens should be used for other purposes than explained above.
Does anyone know any other ways to do this?
Yes, you should definitely use Firebase Anonymous Authentication:
You can use Firebase Authentication to create and use temporary anonymous accounts to authenticate with Firebase. These temporary anonymous accounts can be used to allow users who haven't yet signed up to your app to work with data protected by security rules.

- 130,605
- 17
- 163
- 193
-
Thanks for your answer. It seems to me that Firebase Anonymous Authentication is a temporary solution to avoid having to create accounts - is this correct? – minikate Feb 20 '19 at 13:18
-
1No, it's not. If you don't want to create the actual accounts, you can still use Firebase Anonymous Authentication. It [doesn't expire](https://stackoverflow.com/a/48776702/5246885) and has no down side. I suggest you to go ahead with that. – Alex Mamo Feb 20 '19 at 13:23
-
1Cheers Alex, haven't implemented it yet but it sounds like the way to go. If I am stuck I'll be sure to post on this. – minikate Feb 21 '19 at 16:17
Answer to : Could I use the device token to do this?
Problem with device token is that if I uninstall app and reinstall it is will change . It seems not a good approach because I have not changed phone I just done reinstallation still I lost data . It seems not the functionality you want I think so.

- 54
- 4
-
Okay, thanks for your input. Could you suggest another way of doing this? – minikate Feb 20 '19 at 13:17
You can do your work by getting device IMEI Number, because IMEI number is unique for every device.
TelephonyManager telephonyManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
String imei= telephonyManager.getDeviceId()

- 334
- 1
- 10