adding contact on android

Please provide the following:

  1. SDK Version: 39
  2. Platforms(Android/iOS/web/all): android

I am doing a contacts app using expo-contacts, I can see contacts but the problem comes when I need to add one.

This is the code I am using, the thing is that in some phones works and in other doesn’t. Just to let you know, the permissions to write and read are already attached in app.json.

The error I am getting is this: “Error: insert into content://com.android.contacts/data returned no result.”

Code:

<Button
title=“Guardar”
onPress={async () => {
const contact = {
[Contacts.Fields.FirstName]: “Test”,
[Contacts.Fields.LastName]: “McTest”,
[Contacts.Fields.PhoneNumbers]: [
{
number: “(123) 456-7890”,
isPrimary: true,
digits: “1234567890”,
countryCode: “PA”,
id: “1”,
label: “main”,
},
],
[Contacts.Fields.Emails]: [
{
email: “test@gmail.com”,
isPrimary: true,
id: “2”,
label: “main”,
},
],
};

              await Contacts.addContactAsync(contact)
                .then((contactId) => {
                  alert("Se creó exitosamente");
                })
                .catch((err) => {
                  alert(err);
                  console.log(err);
                });
            }}

The error I am getting is this: Error: insert into content://com.android.contacts/data returned no result.

To finish its important to say that I am using apk already built and not doing in debugging mode in expo.

I will appreciate your answers.

Solved: it was how i organiced data structure to push contact details.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.