incubator-callback-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shazron Abdullah (Commented) (JIRA)" <>
Subject [jira] [Commented] (CB-58) Feature request: contacts.find API too slow for autocomplete. provide max contact objects option.
Date Mon, 28 Nov 2011 22:49:40 GMT


Shazron Abdullah commented on CB-58:


Why don’t you preload the contacts into a object or array, and use that.....

by: Philip C (on

A person could have thousands of contacts. I think that caching all of them is wasteful and
time consuming. Can you think of a way to cache that wouldn’t use too much memory? Do you
normally cache that much?

I wait to autocomplete until the person has typed 2 or 3 letters and then start the process
of auto-completing and showing 3-10 contacts. I think it is reasonable to be able to call
contacts.find and get a response back with up to 10 contacts quickly as you would with a native


Hi Philip

I’m not saying it should be a permanent solution, but just until they approve the feature

But you can easily do it on startup, have splash screen, telling the user that the app is
loading... and prefetch the contacts, and save them in a sql,lawnchair etc.... and the you
could have a hash to check if there are new contacts on each startup....

But the best solution, is to make the solution yourself if you can, and publish it.


Not sure what to say as we are following the W3C Contacts specification (
from December, 2010 and it does not include a limit option.  However, it previously did, so
there is commented out code in Contacts.m that could use a limit parameter if it was provided
in options.  If you want to modify the objective C code in your version of PhoneGapLib you
could get this feature.   

I would ask you to submit this request for a limit parameter to the W3C Device API's working
group that is working on this specification:  

> Feature request: contacts.find API too slow for autocomplete. provide max contact objects
> -------------------------------------------------------------------------------------------------
>                 Key: CB-58
>                 URL:
>             Project: Apache Callback
>          Issue Type: New Feature
>          Components: iOS
>            Reporter: Shazron Abdullah
> reported at:
> by:
> I am trying to use the contacts.find api to fill in an autocomplete box. It is too slow
to be useful in this context.
> Please provide a way to limit the number of contact objects returned from the contacts.find
> Possibly add a new option to contactFindOptions, something like "maxContacts". For example:
>   maxContacts: Determines how many contact objects the find operation should return.
(Integer) (Default: 1000)
> Here is a code snippet of what I am trying to do:
>     $(&rsquo;#contacts input:last&rsquo;).autocomplete({source: function (request,
response) {
>       options = new ContactFindOptions();
>       options.filter = request.term;
>       options.multiple = true; 
>       fields = ["displayName", "phoneNumbers", "emails"];
>       navigator.service.contacts.find(fields,
>         function (contacts) {
>           var responseList = [];
>           console.log(&rsquo;contacts found for &rsquo; + request.term + &rsquo;:
&rsquo; + contacts.length);
>           $.each(contacts, function (index, contact) {
>             //console.log(contact);
>             // limit to 10 autocomplete contacts
>             // note: the contacts.find api takes a long time to return when there are
>             // many contacts that match the options.filter
>             if (index > 10) {
>               return false;  // break
>             }
> [Original LightHouse ticket](
>  This ticket has 0 attachment(s).

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:!default.jspa
For more information on JIRA, see:


View raw message