Cordova contacts find operation fails when there are multiple promises to be resolved.
With respect to below code, when _.times(1
, <contact-number-1>
details will be fetched properly, but when _.times(2
(number > 1) only one contact details is fetched and the promise will get frozen. There is no log of <contact-number-2>
or error or the results
var contacts = [<contact-number-1>, <contact-number-2>, <contact-number-3>];
var promises = _.times(2, function (index) {
console.log('Finding contact: ' + contacts[index]);
return $cordovaContacts
.find({
multiple: true,
desiredFields: ['name', 'phoneNumbers'],
filter: contacts[index],
fields: ['phoneNumbers']
})
.then(function (c) {
console.log('contact');
console.log(c);
return c;
})
.catch(function(error) {
console.log(error);
});
});
console.log('promises.length: ' + promises.length);
$q.all(promises).then(function(results) {
console.log('results');
console.log(results);
});
Any inputs on fixing this issue ?