'undefined' is not a function (evaluating 'navigator.contacts.chooseContact( onSuccess, options)')

1.7k views Asked by At

I have installed cordova 3.0.0 and created a helloworld project, and installed cordova-plugin-contacts. cordova create Helloworld com.example.helloworld "Helloworld" cd Helloworld cordova platforms add ios cordova build cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts.git

and trying to call navigator.contacts.chooseContact

function contactChooser(){
    var options = new ContactFindOptions();
    options.fields = ["displayName", "name", "emails", "phoneNumbers"];
    navigator.contacts.chooseContact( onSuccess, options);
}

but getting this error on safari web inspector.

1

There are 1 answers

1
enRaiser On BEST ANSWER

I found that there is a bug in cordova 3.0.0 ,( i raised ) the namespace were clashing for org.apache.cordova.core.contacts.cotancts

The proper solution to this is as follow Edit org.apache.cordova.core.contacts/plugin.xml and replace contacts to contactxxx as follow

    <js-module src="www/ios/contacts.js" name="contacts_ios">
        <merges target="navigator.contacts" />
    </js-module>

    <js-module src="www/ios/Contact.js" name="Contact_ios">
        <merges target="Contact" />
    </js-module>

and all problem gone

I have raised this bug at https://issues.apache.org/jira/browse/CB-4599 , let us see if they have better solution.