Reputation: 21
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.
<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.
Upvotes: 1
Views: 1455
Reputation: 41
[Contacts.Fields.PhoneNumbers]: [
{
number: "(123) 456-7890",
isPrimary: true,
digits: "1234567890",
countryCode: "PA",
id: "1",
label: "main",
},
]
Changing label from 'main' to 'mobile' worked for me.
Upvotes: 1
Reputation: 21
Solved: it was how i organiced data structure to push contact details.
Upvotes: 1