question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Device uuid is null on platform browser

See original GitHub issue

Bug Report

Device uuid is null on platform browser

Problem

By running ionic cordova run browser device uuid is null as Device object is empty

What is expected to happen?

Device info should be there as it supports browser platform

What does actually happen?

Device object is empty when running the application on browser platform

Information

Here’s my code

import { Device } from '@ionic-native/device/ngx';

constructor(private device: Device) { }

console.log('Device UUID is: ' + this.device.uuid); Result: Device UUID is: null

Command or Code

ionic cordova run browser

Environment, Platform, Device

Platform is browser using chrome

Version information

@ionic-native/device": "^5.5.0

Please help me out how to resolve this problem. I have tested the code on android device. It’s working fine

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
erisucommented, Jul 26, 2019

The browser platform does not have access to the devices UUID. This is why null is returned for the browser platform.

There are alternatives that you can implement on your own for example Fingerprint.js. The goal of Fingerprint.js is to use all of the features that the browser has access to create a unique identifier. They advertise a 99.5% identification accuracy. There is a drawback where a user can do something to make the identifier change.

@janpio for some additional feedback to your question, if the browser had the access permission, the UUID would be most likely related with the OS or a hardware ID.

For example:

  • macOS would fetch the UUID from IOPlatformUUID. If you have a Mac, you can test this with ioreg -rd1 -c IOPlatformExpertDevice | grep IOPlatformUUID
  • Windows would use the MachineGuid from the registry but can be edited with administrator permission.
  • Linux would use the dbus machine-id, but can be changed with root access.

For Electron, I have been looking at some npm modules that would use the information that I posted in the example above. Unfortunately, browser, just does not have the necessary permission to access this level of information of the OS for security reasons. Because of that, users must find alternatives solutions like Fingerprint.js or create their own UUID and store it somewhere like IndexDB.

0reactions
cyptuscommented, Jul 24, 2019

as iOS does not share the UUID which is generated by the plugin from instance to instance (lost after reinstall) i do fallback on a generated GUID which is then saved to localstorage.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Ionic 4 native Device plugin returns device uuid null on ...
Sadly the device.uuid property is not supported on the browser platform. See the supported platforms here. So you might want to check the ......
Read more >
Ionic 4 native Device plugin returns device uuid null on ...
By running ionic cordova run browser device uuid is null as Device object is empty on browser platform. Device info should be there...
Read more >
Ionic 4 native Device plugin returns device uuid ... - Ionic Forum
By running ionic cordova run browser device uuid is null as Device object is empty on browser platform. Device info should be there...
Read more >
plugin device returning empty object : r/ionic
No matter what I do or try I can't get info about the device. I'm using last version of ionic 4. Since all...
Read more >
cordova-plugin-device
Get device information. ... device.cordova; device.model; device.platform; device.uuid; device.version; device. ... Android; Browser; iOS; Windows; OSX ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found