This is a migrated thread and some comments may be shown as answers.

Contact Picker

2 Answers 70 Views
Google Android
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Patrick
Top achievements
Rank 1
Patrick asked on 14 Oct 2013, 04:19 PM
Hi,

How to get access and open the contact data (Addressbook) by clicking on a button.
Pick a contact from the contact list and send it to an input field

Can someone please help me.

Thx

Patrick

2 Answers, 1 is accepted

Sort by
0
Patrick
Top achievements
Rank 1
answered on 15 Oct 2013, 09:24 AM
This is my code:

function onDeviceReadyContacts() {
// find all contacts
var options = new ContactFindOptions();
options.filter = "";
options.multiple = true;
var filter = ["*"];
var fields = ["displayName", "name"];
navigator.contacts.find(fields, onSuccess, onError, options);
}

function onSuccess(contacts) {

var element = document.getElementById('cont');
for (var i = 0; i < contacts.length; i++) {
console.log("Display Name = " + contacts[i].name.formatted);
element.innerHTML = '<li><a href="#">' + contacts[i].name.formatted + '</a></li>';
}
}


Uncaught TypeError: Object #<Object> has no method 'find'
0
Steve
Telerik team
answered on 18 Oct 2013, 08:55 AM
Hello Patrick,

Opening the AddressBook is not supported in Cordova out of the box. There are some custom Cordova plugins out there (like this one), but they target an old Cordova version and are not plugman compatible. Also this one is for Android only and it doesn't seem to be iOS version.

Otherwise, the code looks correct and the error you get could be caused by either:
  • not referencing cordova.js in your html page that triggers the javascript
  • by removing the Cordova Contacts API from your project file.

If you're still having problems, please build your app so that it is uploaded to our cloud and also attach your proj file to this thread (you can rename it as .txt).

Regards,
Steve
Telerik
You've missed the Icenium Visual Studio Integration keynote? It has been recorded and posted here.
Looking for tips & tricks directly from the Icenium team? Check out our blog!
Share feedback and vote for features on our Feedback Portal.
Tags
Google Android
Asked by
Patrick
Top achievements
Rank 1
Answers by
Patrick
Top achievements
Rank 1
Steve
Telerik team
Share this question
or