Question: 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.

Answer: 
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.

```
// uuid.js
.pragma library

function generateUUID(){
    var d = new Date().getTime();
    var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
        var r = (d + Math.random()*16)%16 | 0;
        d = Math.floor(d/16);
        return (c === 'x' ? r : (r&0x3|0x8)).toString(16);
    });
    return uuid;
};

// Elsewhere
U1db.Database {
    id: db
    path: "settings"
}

U1db.Document {
    id: user
    database: db
    docId: "user"
    create: true
    defaults: {
        "userId": ""
    }
}

// Somewhere I need the userId
Item {
    id: thing

    Component.onCompleted: {
        userId: user.contents.userId
        if (!userId) {
             userId = Uuid.generateUUID()
             var userContents = user.contents
             userContents.userId = userId
             user.contents = userContents
        }
        return userId
    }
}

```
This does work. It is how *ubuntu-system-settings* is [getting the IMEI](https://bazaar.launchpad.net/~system-settings-touch/ubuntu-system-settings/trunk/view/head:/plugins/about/PageComponent.qml#L116). 

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.