Results 1 to 10 of 10
  1.    #1  
    I'm trying to get the unique device id by making a service request for system properties. From my understanding, the unique device id (nduid) is the only system property we can retrieve. I've been trying all night to get this to work!!! Can anyone see what I'm doing wrong??? Here is my code (located in the StageAssistant setup function)...

    Code:
    // SET NAMESPACE FOR GLOBAL VARIABLES
    
    	appGlobals = {};
    
    // GET DEVICE ID AND ADD IT TO THE NAMESPACE
    
    	var deviceIDServiceRequestAttributes =
    	{
    		     method: 'getSysProperty',
    		parameters: {'key': 'com.palm.properties.nduid'},
    		 onSuccess: this.deviceIDServiceRequestHandler
    	}
    
    	this.deviceIDServiceRequestHandler = function()
    	{
    		appGlobals.deviceID = response['com.palm.properties.nduid'];
    	}
    
    	this.controller.serviceRequest('palm://com.palm.preferences/systemProperties', deviceIDServiceRequestAttributes);
    MoBill - Use your Authorize.net account to bill your customers with your webOS device!!
    MoJack - Track your lost or stolen webOS device from anywhere!
    Time to get VIRAL
  2. moserjj's Avatar
    Posts
    468 Posts
    Global Posts
    470 Global Posts
    #2  
    Here is what has worked for me. Not very clean but its the only way it work would reliably (so far)

    step 1 - make the request so systemProperties

    Code:
    new Mojo.Service.Request('palm://com.palm.preferences/systemProperties', {
    	method:"Get",
    	parameters:{"key": "com.palm.properties.nduid" },
    	onSuccess: this.handleNDUIDResponse.bind(this)
    });
    step 2 - the onSuccess handler

    Code:
    Yourassistant.prototype.handleNDUIDResponse = function(response){
            var nduid;
    	for (p in response) {
    	   if (p == 'com.palm.properties.nduid') { nduid = response[p]; }
    	}
    hopefully you can modify from this to suit your needs
  3.    #3  
    Thanks!!! I was able to get it working using your example, without having to pull the onSuccess handler outside of the setup function at that. I had to change the last line, replacing "this.controller.serviceRequest" with "new Mojo.Service.Request". Although I forgot to pass "response" to my handler in the example code, it was in my actual app. Here is my code (changes in blue)...

    Note: Page 214 of the Palm webOS book explains why the former wasn't working for me in case anyone is wondering...

    Code:
    // SET NAMESPACE FOR GLOBAL VARIABLES
    
    	appGlobals = {};
    
    // GET DEVICE ID AND ADD IT TO THE NAMESPACE
    
    	var deviceIDServiceRequestAttributes =
    	{
    		     method: 'getSysProperty',
    		parameters: {'key': 'com.palm.properties.nduid'},
    		 onSuccess: this.deviceIDServiceRequestHandler
    	}
    
    	this.deviceIDServiceRequestHandler = function(response)
    	{
    		appGlobals.deviceID = response['com.palm.properties.nduid'];
    	}
    
    	new Mojo.Service.Request('palm://com.palm.preferences/systemProperties', deviceIDServiceRequestAttributes);
    Last edited by Laxidasical; 10/21/2009 at 11:08 AM.
    MoBill - Use your Authorize.net account to bill your customers with your webOS device!!
    MoJack - Track your lost or stolen webOS device from anywhere!
    Time to get VIRAL
  4. moserjj's Avatar
    Posts
    468 Posts
    Global Posts
    470 Global Posts
    #4  
    good deal. more than likely your reference to "this.controller" wasn't working - it depends where you use that on how it works.
  5.    #5  
    CORRECTION!!!

    I DID have to pull the handler function out (and bind it). I thought everything was working as is, but of course it wasn't. It's working correctly now though!
    MoBill - Use your Authorize.net account to bill your customers with your webOS device!!
    MoJack - Track your lost or stolen webOS device from anywhere!
    Time to get VIRAL
  6. #6  
    Anyone mind posting their own device ids?

    I wanna make sure mine looks similar to see if I am doing it right.
  7.    #7  
    This isn't mine, but it's the example in the book...
    (mine is similar in length and char type)

    a66690b3632bb592b29c6a15416717b9ee072b3f
    MoBill - Use your Authorize.net account to bill your customers with your webOS device!!
    MoJack - Track your lost or stolen webOS device from anywhere!
    Time to get VIRAL
  8. #8  
    Quote Originally Posted by Laxidasical View Post
    This isn't mine, but it's the example in the book...
    (mine is similar in length and char type)

    a66690b3632bb592b29c6a15416717b9ee072b3f

    I believe mine is:
    91035bafd2b383aba635dcaf24dfd4a31bb4b6ab

    The emulator's is:
    537260ffffffffff29ffffff6c34730cff39ff4c


    With the above function I am using response[p].
  9. #9  
    Quote Originally Posted by Laxidasical View Post
    CORRECTION!!!

    I DID have to pull the handler function out (and bind it). I thought everything was working as is, but of course it wasn't. It's working correctly now though!
    OK, I think I've done everything to make this work... but it doesn't work. Can you please guide me as to why the following isn't working? My test domain always reports the Device ID as "blahdeblah".

    Code:
    // SET NAMESPACE FOR GLOBAL VARIABLES
    appGlobals = {};
    
    MainAssistant.prototype.setup = function() {
    
    
    
    	appGlobals.deviceID = 'blahdeblah';
    	appGlobals.urlAddress = "mytestdomain/index.php?p=p&uid=";
    
    // GET DEVICE ID AND ADD IT TO THE NAMESPACE
    
    	var deviceIDServiceRequestAttributes =
    	{
    		     method: 'getSysProperty',
    		parameters: {'key': 'com.palm.properties.nduid'},
    		 onSuccess: this.deviceIDServiceRequestHandler.bind(this)
    	}
    
    	new Mojo.Service.Request('palm://com.palm.preferences/systemProperties', deviceIDServiceRequestAttributes);
    
    	var url = appGlobals.urlAddress+appGlobals.deviceID;
    	
    	// Setup up the WebView widget
    	this.controller.setupWidget('defWeb', {
    		url: url,
    		virtualpagewidth: 75
    		}, this.mainViewModel = {});
    	
    	this.controller.setupWidget(Mojo.Menu.appMenu,
    	        this.attributes = {
    	            omitDefaultItems: true
    	        },
    	        this.model = {
    	            visible: true,
    	            items: [ 
    	                Mojo.Menu.editItem
    	            ]
    	        }
    	     );
    }
    
    MainAssistant.prototype.deviceIDServiceRequestHandler = function(response){
    	appGlobals.deviceID = response['com.palm.properties.nduid'];
    }
    I've spent hours and hours banging my head against the desk with this. Your help is appreciated!
  10. #10  
    Quote Originally Posted by socca1157 View Post
    I believe mine is:
    91035bafd2b383aba635dcaf24dfd4a31bb4b6ab

    The emulator's is:
    537260ffffffffff29ffffff6c34730cff39ff4c


    With the above function I am using response[p].
    I will have to check later today what my emulator's nduid is and will post it. I am curious if this could be a method for determining if your app is running on an emulator or on a device? all those "f"s look like they may help me out, maybe emulators allways have x number of "f"s in certain places due to missing hardware?

    Or is there a better method to determine when running on the emulator?

    EDIT: off topic, but there is a better way to check if running on an emulator...
    Forums webOS • View topic - How to determine if env is emulator or hardware?

    Code:
    if (Mojo.Environment.DeviceInfo.modelNameAscii.toLowerCase() === "device") {
    // we're in the emulator -- yes, the emulator's model name is "Device"
    } else {
    // we're in actual hardware which uses the actual model name (Pixi, Pre)
    }
    Last edited by sinime; 12/01/2010 at 09:32 AM.

Posting Permissions