Closed siddiquesheikh30 closed 1 month ago
what's in recordID: data.recordID
? are you passing a recordID
inside route.params
?
Now it is updating correctly, I have to pass rawContactId
, recordId
, and id of number
present in phoneNumbers[]
now my code is working and it is updating the number, givenName, and familyName correctly below is the code for anyone to refer:
const editContact = async () => {
try {
const res = await PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.WRITE_CONTACTS, {
title: 'Contacts',
message: 'This app would like to view your contacts.',
buttonPositive: 'Please accept bare mortal',
});
if (res === PermissionsAndroid.RESULTS.GRANTED) {
const updatedContact = {
recordID: data.recordID,
rawContactId: data.rawContactId,
phoneNumbers: [{
id: data.phoneNumbers[0].id,
label: 'mobile',
number: number,
}],
familyName: lastName,
givenName: firstName,
};
console.log('Updating contact with data: ', updatedContact);
await Contacts.updateContact(updatedContact);
console.log('Contact updated successfully');
// updateContact(updatedContact);
navigation.goBack();
} else {
console.log('Permission denied');
}
} catch (error) {
console.error('Error updating contact: ', error);
}
};
Thank you for taking the time and replying to my issue, just one thing if I want to add an image in contact while adding a new contact or updating a contact how should I do it?
This issue is stale, please provide more information about the status
Now it is updating correctly, I have to pass
rawContactId
,recordId
, andid of number
present inphoneNumbers[]
now my code is working and it is updating the number, givenName, and familyName correctly below is the code for anyone to refer:const editContact = async () => { try { const res = await PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.WRITE_CONTACTS, { title: 'Contacts', message: 'This app would like to view your contacts.', buttonPositive: 'Please accept bare mortal', }); if (res === PermissionsAndroid.RESULTS.GRANTED) { const updatedContact = { recordID: data.recordID, rawContactId: data.rawContactId, phoneNumbers: [{ id: data.phoneNumbers[0].id, label: 'mobile', number: number, }], familyName: lastName, givenName: firstName, }; console.log('Updating contact with data: ', updatedContact); await Contacts.updateContact(updatedContact); console.log('Contact updated successfully'); // updateContact(updatedContact); navigation.goBack(); } else { console.log('Permission denied'); } } catch (error) { console.error('Error updating contact: ', error); } };
Thank you for taking the time and replying to my issue, just one thing if I want to add an image in contact while adding a new contact or updating a contact how should I do it?
Thank you so much :b
Hey @siddiquesheikh30
You might want to check the docs. There’s a function getPhotoForId(contactId)
for that.
I want to edit some details of my contact like givenName, familyName etc. So how can I do it? This is my code so far -
on calling editContact () it is giving me error as
[Error: Invalid recordId or rawContactId]
so what should I do?