Search code examples
mobilefirefox-os

Unable to Get Contacts on FirefoxOS


I have a FirefoxOS device and I am trying to create an application to manage the contacts. I am unable to get the contacts both from the Device and the Simulator (both have 1.3 version) Following is my code (taken from the help):

var cursor = navigator.mozContacts.getAll({});

cursor.onsuccess = function() {
    if (cursor.result) {
        console.log("Got contact with name: " + cursor.result.name.join(" "));
        cursor.continue();
    } else {
        alert("Done!");
    }
};

cursor.onerror = function() {
    alert("Error getting contacts");
    console.log( cursor );
};

Following is the segment from my manifest file:

...
"permissions": {
        "storage": {
            "description": "Required for storing data"
        },
        "contacts": {
            "description": "Needed to access the contacts",
            "access": "readonly"
        }
    },
...

It always falls to the onerror function. Need help.


Solution

  • Did you set in the manifest:

    "type": "privileged",
    

    ?

    Otherwise please post the the value of cursor.error when it fails.