I need to get a unique ID for the device. I originally thought I'd use the device's imei, but that doesn't seem to return anything:
import QtSystemInfo 5.0
DeviceInfo {
id: device
}
Component.onCompleted {
console.log(device.imei(0)) // Returns nothing
}
That may or may not be a bug: https://bugs.launchpad.net/ubuntu/+source/qtsystems-opensource-src/+bug/1197542 but since there haven't been any updates for a year, I'm hoping that maybe I can use some other piece of information.
So, does anyone know how I can get a unique ID for the device? It has to be persistent, but it can be totally meaningless other than as an identifier.
As dobey said, there's no way to get the IMEI in confined apps, so I gave up on trying to get an ID based on the device itself. Instead, I just generate a UUID and store it in U1DB.
This does work. It is how ubuntu-system-settings is getting the IMEI.
Rather, your issue may be that console.log() is not going to whatever console output you're expecting to see it at, or the system you are running it on, has no IMEI available (which requires a GSM modem). There is also a serial number shown in the About page of system settings, but it is being read through a C++ plug-in, which you likely cannot use directly from your app, and may need to reimplement.
Reading the device information is limited to system unconfined apps at the moment. There is no current policy_group to use to be able to read the IMEI in a confined app.
In more recent versions, the
DeviceInfo
QML type has auniqueID
property:Documentation: QML DeviceInfo Element: property uniqueID. (Code not tested, just saw this in the documentation.)