I have web app on desktop and mobile(IOS/Android devices) along with mobile apps, i need to identify the user per device(if user changing the device that can be fine). I think it can be device_id where device id can be machine_id(if feasible to get), would try to avoid the user agent as browser version keeps on updating. How I can get the unique device id in javascript(Front end) for mobile/desktop and send it in request ?
Asked
Active
Viewed 1,536 times
1
-
If this web app runs on the browser, then you can't, at most you might try fingerprinting the user device. – Martheen Jul 08 '21 at 05:45
-
Whats the difference between user device and fingerprinting ? – emilly Jul 08 '21 at 08:02
-
1When you say machine_id you seem to expect an OS-supported method to uniquely identify devices, which due to privacy reason simply isn't possible with browser app alone. Fingerprinting meanwhile just tries to correlate user hardware specs and software config, which is not unique (a fleet of PC or phones provisioned from identical ROM/image would all have the same fingerprint). – Martheen Jul 08 '21 at 08:17
2 Answers
1
/**
* Get Device ID
*
* @param context Activity/Application context
*/
private fun getDeviceId(context: Context): String
{
return Settings.Secure.getString(context.contentResolver, Settings.Secure.ANDROID_ID)
}

shraddha patel
- 628
- 4
- 12
0
May be this can help you
function test () {
if (!navigator.mediaDevices || !navigator.mediaDevices.enumerateDevices) {
alert("enumerateDevices() not supported.");
return;
}
// List cameras and microphones.
navigator.mediaDevices.enumerateDevices()
.then(function(devices) {
devices.forEach(function(device) {
alert(device.kind + ": " + device.label +
" id = " + device.deviceId);
});
})
.catch(function(err) {
alert(err.name + ": " + err.message);
});
} test();

Sergio Marsilli
- 101
- 5