System Properties

Applications can use this service's (com.palm.preferences/systemProperties) one method -- Get -- to request a named system property, which is currently limited to the device ID. The device ID, or nduid, is a 20-byte (160 bit) SHA-1 digest unique to each device.

Note

Your application should not use the device ID to uniquely identify a given user. Because devices may be bought, sold, exchanged, or even serviced in a way that results in a user's device ID changing or being transferred to another user, user data and preferences should never be saved and restored on the basis of the device ID; you should implement your own account management system for this purpose.


Get

Requests the named system property.

Syntax

{
    "key" : string
}

Parameters

Parameter Required Type Description
key Yes string Set to "com.palm.properties.nduid" to request device's unique ID.

Returns

{
    "returnValue"               : boolean,
    "com.palm.properties.nduid" : string,
    "errorText"                 : string
}
Attribute Requied Type Description
returnValue Yes boolean true (success) or false (failure).
com.palm.properties.nduid No string Device's unique ID.
errorText No string Error message returned on failure

Examples

Enyo

enyo.kind({
   name : "enyo.SysProps",
   kind : enyo.VFlexBox,
   components : [ 
     { flex : 1,
      kind : "Pane",
      components : [{
         flex : 1,
         kind : "Scroller",
         components : [{
            name : "getSysProp",
            kind : "PalmService",
            service : "palm://com.palm.preferences/systemProperties",
            method : "Get",
            onSuccess : "getSysPropSuccess",
            onFailure : "getSysPropFailure",
            subscribe : true
         },
         {kind : "Button", name : "getPropButton", caption : "Get System Property", onclick : "getSysPropClick"}
        ]
      }]
    }],
    getSysPropClick: function() {       
         this.$.getSysProp.call({"key": "com.palm.properties.nduid"});
    },
    getSysPropSuccess: function(inSender, inResponse) {
        this.log("Get Device ID success, results=" + enyo.json.stringify(inResponse));
    },          
    // Log errors to the console for debugging
    getSysPropFailure: function(inSender, inError, inRequest) {
        this.log(enyo.json.stringify(inError));
    }
});

Mojo

this.controller.serviceRequest('palm://com.palm.preferences/systemProperties', {
    method:"Get",
    parameters:{"key": "com.palm.properties.nduid" },
    onSuccess : function (e){ Mojo.Log.info("Get Device ID success, results="+JSON.stringify(e)); },
    onFailure : function (e){ Mojo.Log.info("Get Device ID failure, results="+JSON.stringify(e)); }
});

Success

Get Device ID success, results=
{
    "com.palm.properties.nduid": "144872d8a7610e9c615a940ad99c5c82e0cec0ff", 
    "returnValue": true }
}

Failure

Get Device ID failure, results=
{
    "errorText"   : "No such key", 
    "returnValue" : false }
}

Sample Code

See Services Sample in the SDK.