Flutter get device serial number or any other unique identifier - android

I am making an app where the user has to register their device first and I can block user if they use device that are not registered, and therefore I need some unique ID from their device. I used device_info_plus and unique_identifier packages and got some unique information from the device. The problem is the user have no way of obtaining the information needed for registration like the one gotten from unique_identifier(ANDROID_ID).
Is there a way to obtain hardware serial number programmatically? Because that seems to be the only one usable for this case, or is there any other unique ID to identify a device that is obtainable both from user and programmatically?

You can use the package uuid.
Than call this method to obtain an unique id based on the device (it does not contain device's hardware data but:
String uuid = const Uuid().v1();

Related

How to block multiple signup with different mobile number?

I'm developing an android app which contains registration form also,
Here I want to make user can register only once in the device. and if register again (by clearing data or reinstall) with different mobile number and email id, app should give error message.
I think you need to check IMEI number of device
IMEI number will not be changed if sim card changed.
This alone cannot be achieved on mobile device itself. You also need to maintain server which keep the identity of device and user mobile number together. device identity can be combination of IMEI and device id
When you try to register, you do all local validation on client but ultimately 1 network call is must to register, for this send device_id and newly registered number.
Next time when some user tries to register with new number from same device, u'd already have this information on server, server can respond back telling, hey looks like this mobile device is already associated with an number do you wish to use the previous number instead.
In case, user denies, he must be allowed to delete the old relation between oldnumber-current device.
There after he can proceed with the way initially he started to register.
Also this is completely business requirement, whether u want to have 1device-> #numbers or #numbers -> 1device. But i would rather suggest to keep it safe simple and secure with 1device->1number.
For Android Version 6 And Above, WLAN MAC Address has been deprecated.
For uniquely Identification of devices, You can Use Secure.ANDROID_ID.
And we don't need any additional permission to retrieve Android ID.
you can get Android Id like:
public String getDeviceUniqueID(Activity activity){
String device_unique_id = Secure.getString(activity.getContentResolver(),
Secure.ANDROID_ID);
return device_unique_id;
}
You can do this by below approach.
On sign up, get user device IMEI number as well and store on server database as well.(In this step make sure that user that IMEI number does not exist)

How to get unique id for clients without registration? (Jodel app for e.g)

Imagine an application that consists of loads of clients and one server. The clients should be able to use the application without the need to register a username for e.g. (Therefore getting the feeling of anonymously using the app)
What unique data in a smartphone could be use to identify "anonymous" users and seperate them uniquely, so that each user would have its own personal data.
Could one use the IMEI id?
Is this possible?
At I/O 15 Google announced the 'instance ID' which uniquely identifies an app installation, and can be used for a veriety of other purposes as well.
I give more detail in an answer to an existing, similar question here:
https://stackoverflow.com/a/30948111/150016
Yes You can use the IMEI, but then you need a permission...or you could give every User a Unique ID on the server side
I think a long type variable is enough so the first one that connects you give him the ID 1 the app gets the ID and so on and so forth
You can use a built in feature here:
import android.provider.Settings.Secure;
private String uniqueIdentifier = Secure.getString(getContext().getContentResolver(),
Secure.ANDROID_ID);
where Secure.ANDROID_ID is presented as "A 64-bit number (as a hex string) that is randomly generated when the user first sets up the device and should remain constant for the lifetime of the user's device."
This is exactly the use case for the new Instance ID: getting a unique ID that you can use to identify even a not logged in user to your server.
This works on both phones and tablets (something IMEI does not) and avoid issues with ANDROID_ID (such as a few manufacturers always using the same ANDROID_ID on all devices).
You don't want to use the IMEI, as it will only apply to devices that have cell phones in them. There are plenty of wifi only devices out there in the wild.
Also, to get the IMEI, you need to ask for extra permission in your manifest.
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
You'd be better off either generating your own random GUID and storing it in your app's SQLite database, or use the Android ID field.
Android ID will give you extra benefits like providing a different identifier for different user profiles within a device.
Another answer here mentioned using Instance ID, but the big caveat there is it requires Google Play Services, so your app wouldn't work on AOSP / forked devices (i.e. Amazon's tablets). I'd have just inserted this as a comment to that answer, but my rep won't let me comment yet.

How can I generate a unique ID to be use as session id on the server side?

According to the net, the most recommended method in generating unique id is to use the Settings.Secure.ANDROID_ID. However, Settings.Secure.ANDROID_ID has a bug on Android 2.2. I am using Android 2.2 so I can't use it. On the other hand, there is also the mac address of the wiFi device and the TelephonyManager.getDeviceId(). The ID that I will be generating will be used as the session ID on the server side so it must be unique.
Will I be okay with just using the mac address of the wiFi as my unique ID and the device ID of the phone as fallback if the device has no wiFi interface? The application needs connection to the internet and so a wiFi interface or deviceId for phone will surely be present right? Or is it a bad idea?
I am also considering the use of UUID.randomUUID(). But even though there is a very small chance of generating the same id here, the probability still exist.
What ID can I use if that ID must also serve as session ID on the server? Also, please note that if the ID is already existing on the server, the ownership of the session will be given to the new user.
You can simply create a random ID (UUID is fine for that) on the server. Then you can ensure it's not in use yet.
I used ANDROID_ID, but i added random number in front of it and i get a random number...i check it if i had it in the base and if not i used that number...
The device id is unique. What's wrong getting it ?

Unique identifier for each phone Android

I want to create an application where the application will ask user to register with user details while using the app for the first time. This information will be stored in a remote database. Next time when user opens the application I want to identify the user from my database.
Now to implement this, I will have to find a unique identifier for each phone.
Could anyone let me know how to get unique identifier for each phone.
Regards,
Shannkar
You should read this: http://android-developers.blogspot.com/2011/03/identifying-app-installations.html
The problem with using the phone number is phone numbers change, get recycled, etc. SIM cards change. Get swapped. Etc. I've had real production experience with this.
I've had good results having users enter their serial# or ESN.
Or use the IMEI. You should be able to access it via the API.
If you want it automated, and cannot access the ESN or IMEI, then generate a GUID and store it on persistent storage in the device.
You can use IMEI as the unique identification.you can get IMEI of android device in the following way
TelephonyManager tManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
String uuid = tManager.getDeviceId();
check my similar question here to get IMEI (UUID) number
How can I get the UUID of my Android phone in an application?

how to get the device(android) tel number or other device unique id which can be taken from the system

I want to enter an website using the tel num as a password how do i get it using the android API is it possible ?
or is there another key value on the android which is unique and I can ask him from the android system , android devices and therefore security is promised?
If you need a unique ID you can use the ANDROID_ID. It is unique for a device:
String id = Settings.Secure.getString(context.getContentResolver(),
android.provider.Settings.Secure.ANDROID_ID);
(context could be your Activity or otherwise)
You probably shouldn't send this ID out unchanged; it would be better to do a hash on it first.
I think that's not possible due security reasons.
For example, some apps which really need your number like Skype lite ask user to enter it manually.

Categories

Resources