nativescript-contacts icon indicating copy to clipboard operation
nativescript-contacts copied to clipboard

getAllContacts only returns contacts the first time

Open fpaaske opened this issue 5 years ago • 2 comments

After updating to NativeScript 6.5 and tns-android 6.5.0, getAllContacts(["name"]) only returns contacts the first time it's called.

I tested some older versions, and for NativeScript 6.5 and tns-android 6.4.0, the same code works well.

But for NativeScript 6.5 and tns-android 6.4.1 it fails again..

fpaaske avatar Apr 23 '20 19:04 fpaaske

Your issue prompted me to test my own app that uses getAllContacts. It works successfully on an Android emulator. Where were you seeing the problem?

tns doctor output:

✔ Component nativescript has 6.5.0 version and is up to date.
✔ Component tns-core-modules has 6.5.1 version and is up to date.
✔ Component tns-android has 6.5.0 version and is up to date.
✔ Component tns-ios has 6.5.0 version and is up to date.

BTW, I found an issue in the getContact method where the activityResult callback is called multiple times, once for each time getContact has been invoked. I have a local fix that removes the event listener upon completion and will be making a pull request. I looked at the getAllContacts method but this problem doesn't appear to exist there.

dlcole avatar Apr 24 '20 13:04 dlcole

I have a local fix that removes the event listener upon completion and will be making a pull request.

Alternatively you can just unsubscribe the eventlistener then create a new event listener in case you don't have subscriptions.

this.contacts.contactsFound.unsubscribe(); this.contacts.contactsSaved = new EventEmitter<Object>();

comporell avatar Jun 14 '20 22:06 comporell