firescript / nativescript-contacts

A nativescript module that gives access to the native contact directory.
MIT License
28 stars 32 forks source link

[Android] contact.delete() fails with exception "Error optaining group id" #92

Open dlcole opened 3 years ago

dlcole commented 3 years ago

I'm encountering an exception with contact.delete() on an Android device (works OK on emulators). The problem occurs with line 438 of contact-model.android.js:

var rawIdCursor = contentResolver.query(android.provider.ContactsContract.RawContacts.CONTENT_URI, ["_id"], "_id = " + id, null, null);
if (!rawIdCursor.moveToFirst()) {
    throw new Error("Error optaining group id");
    return;
}

So far I haven't been able to determine why rawIdCursor.moveToFirst() fails. At this point I'd welcome any insights. This is with the current plugin version, 1.6.2, and {N} 6.8.0.

[edit]

I was only seeing this on one of two devices, so I reset the failing device to factory settings but am still seeing the same problem, except when I also see issue 83 which prevents my deleteContact() from firing.

firescript commented 3 years ago

@dlcole was this resolved?

dlcole commented 3 years ago

No, I've made no progress on this.

dlcole commented 2 years ago

I never really resolved this, and then hit the error again recently when doing some regression testing. My app allows users to add contacts and later remove them. I call getAllContacts() to get the organization name, and if it's the name of the associated event (unique to the contacts I create), I delete it.

I was hitting this error consistently, then changed the code to use getAllContactsWithoutWorker(). I can now delete all the contacts I had earlier added, and this problem no longer occurs. So, this seems like a viable bypass.

Note: I am now using the @nativescript/contacts version of the plugin.

dlcole commented 2 years ago

I spoke too early. The problem still exists; I had commented-out the Throw to do some debugging :-(. I'm not finding a use case where I can delete a contact successfully on Android, but I have to presume most people can or I'd see more issues. Maybe Google syncing the contacts is part of the issue?