facebook

Device is not defined

  1. MobiOne Archive
  2.  > 
  3. Getting Help – General
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #353396 Reply

    Darshan Patel
    Participant

    my device ready function seems to be executing before the device is ready…

    this is the code

    phoneui.documentReadyHandler = function() {
    alert(device.uuid);
    }

    its shows error : Uncaught ReferenceError: device is not defined

    this was working fine till now.. but it started to show error when i changed my first page to some other page…

    so i also tried creating a new blank project but still it shows the same error…

    i have found the workaround for this… but still can you please check what the issue is?

    thanks..

    #353398 Reply

    support-michael
    Keymaster

    >its shows error : Uncaught ReferenceError: device is not defined
    >this was working fine till now.. but it started to show error when i changed my first page to some other page…

    2 thoughts:
    1) compare your new start page to the original working page. Make sure you are including cordova.js correctly

    2) if the new startup page has a different name then in your config.xml file make sure the following entry is properly configured with the startup file name.

    <content src=”yourstartupfile.html”/>

    Optionally if your startup file is named index.html you can remove or comment out the <content> element.

    Lastly, how are you building your project?

    #353408 Reply

    Darshan Patel
    Participant

    i am using M1..

    i tried this thing in a fresh project.. still the same error..

    the issue is that the device info is not available when deviceready is fired.. it is available a sec later..

    like this doesnt works

    phoneui.documentReadyHandler = function() {
    alert(device.uuid);
    }

    but this does

    phoneui.documentReadyHandler = function() {
    setTimeout(function (){alert(device.uuid);},1000);
    }

    #353417 Reply

    support-michael
    Keymaster

    I’ll try replicating this. Please provide the following info:

    1) What mobile platform, ios or android?

    2) How are you building the project? Are you using MobiOne to build the app or another mechanism such as MyEclipse + PhoneGap Build or a local SDK?

    3) Can you share a small sample project that demo’s this issue?
    I can gen one but then it will not be a true apples-apples test.

    #353449 Reply

    Darshan Patel
    Participant

    platform -> IOS

    how -> mobione

    Attachments:
    You must be logged in to view attached files.
    #353464 Reply

    support-michael
    Keymaster

    my apologies as I had a brain fart last week thinking you were receiving a deviceready callback…

    Here’s the approach you should take. In your documentReadyHandler() function register the phonegap/cordova deviceready event handler. That should do it. The documentReadyHandler() is call when the html document completes loading. You must wait for cordova to send the deviceready event before using any cordova or plugin api.

    phoneui.documentreadyhandler = function() {
      document.addEventListener("deviceready", function() {
                alert(device.uuid);
      }
    }
    #353507 Reply

    Darshan Patel
    Participant

    thanks…

Viewing 7 posts - 1 through 7 (of 7 total)
Reply To: Device is not defined

You must be logged in to post in the forum log in