Closed pavlo-o-savchuk closed 2 years ago
not sure.
Hello @pavlo-o-savchuk , actually you pass wrong object of contact for update contact. actually only pass contact not contact[0]
Ex :
contacts[0].hasThumbnail = true; contacts[0].thumbnailPath = path;
Contacts.updateContact(contacts, (error, result) => { console.log(error) console.log(result) })
Try above snippet of code
Thanks
@kruz123 thank you for your answer, I do exactly as you suggested and still, the contact and logs give me no error at all, though the contact remains without the image. However, on the ios it works perfectly.
const contact = {
familyName: 'Harry - Smith',
phoneNumbers: [
{
label: 'work',
number: '+4578729922'
}
],
hasThumbnail: true,
thumbnailPath: 'https://api.maguru.dk/normal_contact.png'
}
In addition to this, I tried to download the image, move it from the Android temp directory to the gallery. having given access to files, galleries, I try to apply the image path instead of URL - it also did not work. No error, nothing, the contact is not hust being updated.
If you have any snippet of code, that does work, can you please share it? In any case, I appreciate your help and suggestions. p.s. the workaround could be to download the files, move them to the gallery and then check, if the contact does not have the image show the button on the UI "set the contact profile image" and then, when the user clicks on the button, we can open a contact profile form, where the user can set the image manually. Still, the goal is to make it automatic.
hello @pavlo-o-savchuk can you please share your code i didn't understand your problem
Thanks
Ok, I am trying to create a contact on the android device with the profile image.
This is what I do:
const contact = {
familyName: 'Harry - Smith',
phoneNumbers: [
{
label: 'work',
number: '+4511223344'
}
],
hasThumbnail: true,
thumbnailPath: 'https://api.maguru.dk/normal_contact.png'
}
Contacts.addContact(contact , error => {
console.log('Contact ', contact )
console.log('Error ', error)
})
The code above creates a contact in the native contacts app. BUT, without profile image. Then, I try to download the image file. After the download, the android places the image file in the temp directory. The next step is I am moving the image from the temp directory to the android native gallery and I get the path for the image on the device. I can see the image appear in the gallery. After that, I am searching the contact in the contact native app by phone number. If contacts exist I try to update it, setting the path to it. Still, the image is not set on the contact profile. When I call getAll(), I get the array of contacts as JSON objects. The needed object has values hasThumbnail as false, thumbnailPath: "" However, the changes in the first name or last name are applied, if I change them with the path hasThumbnail and thumbnailPath. This is how I try to update the contact with the image path:
Contacts.getContactsByPhoneNumber('+4511223344', (error, contacts) => {
// At this point I have found a needed contact
console.log('Contacts', contacts )
console.log('Error ', error)
// Now I am setting the needed values to the object I found.
contacts[0].hasThumbnail = true
// both image path ot URL of the image have no effect on it
contacts[0].thumbnailPath = path
Contacts.updateContact(contacts[0], (error, result) => {
console.log(error)
console.log(result)
})
})
This issue is stale, please provide more information about the status
@pavlo-o-savchuk can you solve this issue ? please update the status for this issue.
No, the issue remained. I could not make the contact be created with the contact image on the Android device.
This issue is stale, please provide more information about the status
issue remained.
This issue is stale, please provide more information about the status
is anyone resolved this issue?
@adilijaz eventually we decided to abandon the contact thumb image for android and focus on tasks with higher priority.
Hi,
When I create or update a contact with the contact object it does not save the contact profile image on Android.
Below "path" is either a URL address of the image or the path of the downloaded image on the device and saved.
trying another approach also does not work.
Any suggestion on how to save a contact profile image for the existing or a new contact? Please advice