6

My use case is I want to uniquely identify my users devices as I want to provide them subscription and dont want to use any type of login instead use an unique identifier that I can save it on my backend so even if user uninstall or reinstall my app, still be able to access content. Also I've had tried to use androidId (SSAID) but it can change on app signin change or device reset. I am using firebase as backend and flutter on front end.

Crate
  • 63
  • 4

2 Answers2

2

You can use the library below in order to find the device's unique ID:

Device ID library

Also this is a duplicate question, so please take care next time to search for the answer prior to asking a question. :)

Lastly, I am not entirely sure of the scope of your project but if you saving user data, sensitive or not on Firebase, logging people in with the devices UID's could be problematic for example in the situation of the user losing their phone they would not be able to recover their lost data. Like I said I'm not sure the scope of your project but just something to think about.

Please let me know if you need any further help!

dotmp3
  • 494
  • 4
  • 13
  • Hey thanks for your quick response but as I mentioned I've already tried using this device_info (SSAID) but it changed 2 3 new builds so I cannot use this further, secondly I'm not using users sensitive information so user do not need to worry about it, if you can suggest any other ways to achieve this let me know – Crate Nov 08 '20 at 00:37
  • Please check out the duplicate question I put in my answer as there are a few others ways and libraries of doing it. I am also just curious as to why you even have a database on the cloud if you are not concerned whether the users data is lost or not, why not use a local database? – dotmp3 Nov 08 '20 at 00:41
  • Didn't seem to find your answer, can you please refer it here and I'm using firebase because I'm providing access to premium content in my app as the user purchases the plan, the plan amount, content all are fetched from db as well as I'm using it for push notification – Crate Nov 08 '20 at 00:55
  • And I'm wondering I had a build of my app 3 months ago and it's giving me different ssaid as compared to the build I made yesterday and fun fact I didnt even reset my phone also and tried checking from my friend's device got the same result as mine (showing different ssaid) – Crate Nov 08 '20 at 01:00
  • 1
    I reviewed the answer I was looking at and it seems that the library is discontinued so maybe try this [library](https://pub.dev/packages/platform_device_id) as well as look at [dart packages](https://pub.dev/packages?q=device+id).I would suggest from what I can see using the devices UID's without a backups such a email and password sign in is rather risky and assuming you are storing the UID's in the database directly a hacker could potentially steal all of those UID's unless salted and its possible to get other users device ID's. Look, go with what you think is right, but thats just my view. – dotmp3 Nov 08 '20 at 01:13
  • yes I've taken email and attached to every uuid but if I roll out an update the new build, the uuid is not similar as previous one as it should be, so I've to ask the user for there email to give them access also cannot use this uuid as it will change after new releases. – Crate Nov 08 '20 at 01:49
0

This is how to get unique identifier for the device:

For Android using the unique_identifier library to get the IMEI:

// Add this dependency to pubspec.yaml
dev_dependencies:
  unique_identifier: ^0.0.3

// code snippet to get the IMEI 
String  identifier = await UniqueIdentifier.serial;

For IOS, Apple no longer allows you to retrieve the IMEI but you can generate UDID similar to the IMEI:

import 'package:device_info/device_info.dart';

final DeviceInfoPlugin deviceInfoPlugin = new DeviceInfoPlugin();
   var data = await deviceInfoPlugin.iosInfo;
   identifier = data.identifierForVendor;
dotmp3
  • 494
  • 4
  • 13
Khalil LAABOUDI
  • 244
  • 1
  • 2
  • 12
  • Does it change overtime or when device reset? Also does it change in lifetime ? or is it doesnot change – Crate Nov 08 '20 at 01:52
  • No, IMEI number does not change after factory reset. Since the IMEI number is a part of the hardware, therefore, any reset that is software-based will not be able to change the IMEI of your phone. – Khalil LAABOUDI Nov 08 '20 at 01:54
  • 2
    Crate, please don't forget to mark the correct answer for future to see. :) – dotmp3 Nov 08 '20 at 01:59
  • okay seems fair, but as I searched about if I've dual sim phone, I would be getting 2 IMEI's – Crate Nov 08 '20 at 02:00
  • I'll get back to this post after I try these solution. Glad you guys helped !! – Crate Nov 08 '20 at 02:02