Is there a way to asynchronously load contacts?

I have 10,000 contacts. When i try to load contacts, it takes too much time plus very slow performance. Is there any work around to load contacts asynchronously or something else ?

Any help would be highly appreciated.

Hi, I believe there were plenty of discussion about this issue on this forum.

But here are some options:

  1. collection-repeat is a directive that allows you to render lists with thousands of items in them, and experience little to no performance penalty.

  1. The ionInfiniteScroll directive allows you to call a function whenever the user gets to the bottom of the page or near the bottom of the page.

combination with track by id if using ng-repeat and limitto to limit how many items item you load should give you a better performance.

That resolves the rendering problem. I have 10,000+ contacts in my device, which takes long to return from plugin. I am not having rendering issue. Contacts plugin is responding too late.

1 Like

Can you not request them in parts like first 100 then the next 100

How can i do that? That would be great if you can share some code.

Well, i wrote a new plugin to fix my issue. Not a very good one, but it solves my problem.

Unfortunately I have to support Android as well as ios, so @mrameezraja plugin will not work for me.

I am running into same issue except that on Galaxy s1, 4.2.2 it takes about 24 seconds to load 700 contacts. However some of my users are not able to load any contacts it just hangs and never hides loading indicator. I was wondering if anyone saw a weird contact character or missing field that would cause the process of loading contacts to brake? Also the error callback is never called.

I’m having this issue as well. Contacts load instantly on iOS but take 8 seconds on my Nexus 5 with maybe 500 contacts. I’m worried this will be even longer on worse hardware or for more contacts.
Rendering isn’t an issue, I put timings in and the time is all spent actually retrieving the contacts in the $cordovaContacts.find call.

It must be possible to improve this somehow because I tested this app:

Which appears to use Ionic and loads the contacts instantly on the same device.

I’m just doing a simple find:

var options = {};
options.multiple = true;

$cordovaContacts.find(options).then(onSuccess, onError).finally(function () {
      $scope.isloadingSpinnerVisible = false;

There’s no problem to asynchronously load contacts with the official plugin. Creating a simple service that returns a promise solves the problem.

The strategy we use to load contacts is the next one:

  • We have a “ContactsService” factory with two main methods, “loadContacts” and “getContacts” and a private var “contactsLoadedPromise”, which is resolved when the contacts are loaded.
  • On device ready we run the “loadContacts” method that calls the cordova contacts plugin and fetches all the contacts needed by our app. We store the contacts list in an array inside the factory. When the load is complete we resolve the promise “contactsLoadedPromise”.
  • Then, any time we need the contacts in our app, we call the “ContactsService.getContacts” that returns the contact list stored in the factory. This method doesn’t get resolved until the “contactsLoadedPromise” is resolved.

Hope it helps you.

1 Like

hi @jonmikelm,

could you show us the example code in “ContactsService” and an example code when we call the “ContactsService.getConatcts” ?
I need that code because i still dont get how to do it.
Thanks in advance.

Hi , Your problem (loading 10000 contacts) has solved or not?

Hi guys, any update on this. I am using cordova contacts plugin which has only 3 methods - create,find & pickContact. And its freezing UI in IOS.