Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 

fuse-device

Use the basic Device functions such as UUID and current localization from Fuse.

Installation

Using fusepm

$ fusepm install https://github.com/MaxGraey/fuse-device

Or manually copy Device.uno to your project and add link in .unoproj see example

Support

  • iOS
  • Android
  • Preview

JavaScript

    var Device = require('Device');

    console.log('Current device language: ' + Device.locale); // format in BCP-47 for all mobile platforms
    // output example: en-US

    console.log('UUID:'                + Device.UUID);
    // output example:
    // UUID: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX

    console.log('Vendor name: '        + Device.vendor);
    console.log('Model name: '         + Device.model);
    console.log('System: '             + Device.system);
    console.log('System version: '     + Device.systemVersion);
    console.log('System SDK ver: '     + Device.SDKVersion);
    console.log('Logical processors: ' + Device.cores);
    console.log('is retina?: '         + Device.isRetina);

Since reading UUID in Android requires a run-time permission to READ_PHONE_STATE, the UUID might not always be accessible via Device.UUID directly. To work around that, there is a getUUID() method that returns the UUID in a promise.

For convenience, getUUID() is available on all target platforms, but it only triggers the permission request on Android.

    var Device = require('Device');
    if (Device.UUID == '') {
        Device.getUUID().then(function(uuid) {
            console.log('UUID: ' + uuid);
            // output example:
            // UUID: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
        }).catch(function(error) {
            console.log('UUID error: ' + error);
            // output example:
            // UUID error: Permissions could not be requested or granted.
        });
    }

About

Use the basic Device functions such as UUID and current localization from Fuse

Topics

Resources

License

Releases

No releases published

Packages

No packages published

Languages