Software Archive
Read-only legacy content

intel.xdk.device.ready is not firing

Rob_Welan
New Contributor I
382 Views

My onDeviceReady function is not firing in my iOS app. My app works perfectly in the emulator and the Intel App Preview. When I build the app and test the ipa on my iPhone, none of the alerts appear, so I know that the onDeviceReady is not firing at all.

Here are my HTML scripts in the index.html file:

        <script src="cordova.js" id="xdkJScordova_"></script>
        
        <script src="js/app.js"></script>
        <!-- for your event code, see README and file comments for details -->
        <script src="js/init-app.js"></script>
        <script src="xdk/init-dev.js"></script>
        <script type="text/javascript" src="js/weatherapi.js"></script>
        <!-- for your init code, see README and file comments for details -->
        <!-- rw <script type="text/javascript" src="device.js"></script>
        <script type="text/javascript" src="RemoteDataParameters.js"></script> -->
        <script type="text/javascript" src="js/globalization.js"></script>
        <script type="text/javascript" src="js/GlobalizationError.js"></script>
        <script type="text/javascript" src="js/geolocation.js"></script>
        <script type="text/javascript" src="js/Coordinates.js"></script>
        <script type="text/javascript" src="js/Position.js"></script>
        <script type="text/javascript" src="js/PositionError.js"></script>
        <script type="text/javascript" src="js/statusbar.js"></script>
        <!-- normalizes device and document ready events, see file for details -->
        <!--
        You may substitute jQuery for the App Framework selector library.
        See http://app-framework-software.intel.com/documentation.php#afui/afui_jquery
        -->
        <script type="application/javascript" src="app_framework/2.1/appframework.js"></script>
        <script type="application/javascript" src="app_framework/2.1/appframework.ui.js" data-ver="1"></script>
        <script type="application/javascript" src="js/index_user_scripts.js"></script>
        <script type="application/javascript" src="xdk/ad/af_subpage.js"></script>

You'll notice I've remmed out the 'device.js' and 'RemoteDataParameters.js' libraries (from the Intel XDK bit). It doesn't matter if they are remmed out or not. All of my plugins work fine except for the Intel one. I have checked that I've included the plug-ins, including the intel one on the project page. I've also checked the build, and the build says "Plugin "intel.xdk.device" (1.2.5) installed."

Here's my onDeviceReady function:

app.onDeviceReady = function() {
    "use strict" ;
    var fName = "app.onDeviceReady():" ;
    alert('before status');
    intel.xdk.device.hideSplashScreen();
    StatusBar.overlaysWebView(false);
    StatusBar.styleLightContent();
    StatusBar.backgroundColorByName("black");
    alert('after status, before globalization');
//>>    NOTE BELOW: Globalization Only Works in App, not in Emulator!
        navigator.globalization.getLocaleName(onSuccessLocale, onErrorLocale);
        navigator.globalization.getDatePattern(onSuccessDatePattern, onErrorDatePattern);
//>>    NOTE ABOVE: Globalization Only Works in App, not in Emulator!
    alert('after globalization, before islocal');
    if (gSS.isLocalBeingCalled) {
            navigator.geolocation.getCurrentPosition(onSuccessPosition, onErrorPosition, { maximumAge: 3000, timeout: 5000, enableHighAccuracy: true }); }
    alert("device is ready");
} ;

and the call:

document.addEventListener("intel.xdk.device.ready", app.onDeviceReady, false);

Help please.

0 Kudos
1 Solution
Rob_Welan
New Contributor I
382 Views

I fixed this!

In Build 2673, I built an entirely new app. I used the default js/init-dev.js file, and the dev.onDeviceReady function. This file now uses:

window.addEventListener("load", function(){window.setTimeout(dev.initDeviceReady,dev.WINDOW_LOAD);}.bind(dev), false) ;

instead of:

document.addEventListener("intel.xdk.device.ready", app.onDeviceReady, false);

At time of this post, "intel.xdk.device.ready" appears to be semi-depricated... I can't remember where I read this, somewhere in the Intel XDK documents.

View solution in original post

0 Kudos
1 Reply
Rob_Welan
New Contributor I
383 Views

I fixed this!

In Build 2673, I built an entirely new app. I used the default js/init-dev.js file, and the dev.onDeviceReady function. This file now uses:

window.addEventListener("load", function(){window.setTimeout(dev.initDeviceReady,dev.WINDOW_LOAD);}.bind(dev), false) ;

instead of:

document.addEventListener("intel.xdk.device.ready", app.onDeviceReady, false);

At time of this post, "intel.xdk.device.ready" appears to be semi-depricated... I can't remember where I read this, somewhere in the Intel XDK documents.

0 Kudos
Reply