nativescript-contacts
nativescript-contacts copied to clipboard
[Android] contact.delete() fails with exception "Error optaining group id"
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.
@dlcole was this resolved?
No, I've made no progress on this.
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.
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?