Search code examples
htmlintel-xdkintel-xdk-contacts

intel-xdk: not able to get contacts list


I am not able to get contacts list.

HTML Code:

<!DOCTYPE html><!--HTML5 doctype-->
<html>
<head>
    <meta http-equiv="Content-type" content="text/html; charset=utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0" />
    <style type="text/css">
        /* Prevent copy paste for all elements except text fields */
        *  { -webkit-user-select:none; -webkit-tap-highlight-color:rgba(255, 255, 255, 0); }
        input, textarea  { -webkit-user-select:text; }
        body { background-color:green; color:black }
    </style>
    <script src='intelxdk.js'></script>
    <script type="text/javascript">
        /* This code is used to run as soon as Intel activates */
        var onDeviceReady=function(){
        //hide splash screen
          intel.xdk.device.hideSplashScreen();
        };
        document.addEventListener("intel.xdk.device.ready",onDeviceReady,false);
    </script>
</head>
<body>
    <script>
        document.addEventListener('intel.xdk.contacts.get', contactsReceived, true);

        function contactsReceived() {

            alert("contacts recieved");

            var table = document.getElementById("contacts");
            table.innerHTML = '';

            var myContacts = intel.xdk.contacts.getContactList();

            alert("Contacts length: "+myContacts.length);
        }
    </script>
</body>
</html>

intel.xdk.contacts.get event is not fired. Is it a bug ?


Solution

  • I was not calling intel.xdk.contacts.getContacts() inside onDeviceReady. Found this from the post here.