firescript / nativescript-contacts

A nativescript module that gives access to the native contact directory.
MIT License
28 stars 32 forks source link

Photo issue to base64 #45

Open jmfsilva opened 6 years ago

jmfsilva commented 6 years ago

Platform: ios

method call: getAllContacts()

config: const desiredFields = ["name", "phoneNumbers", "photo"];

code called: contact.photo && contact.photo.toBase64String("png")

Error: getAllContacts Catch: TypeError: contact.photo.toBase64String is not a function. (In 'contact.photo.toBase64String("png")', 'contact.photo.toBase64String' is undefined)

This happens on the first object with image:

{
"id": "412412412",
"name": {
"given": "Bill",
"middle": "",
"family": "Jobs",
"prefix": "",
"suffix": "",
"displayname": "",
"phonetic": {
"given": "",
"middle": "",
"family": ""
}
},
"organization": {
"name": "",
"jobTitle": "",
"department": ""
},
"nickname": "",
"notes": "",
"photo": {
"ios": {}
},
"urls": [],
"phoneNumbers": [
{
"id": "12412412412412",
"label": "Mobile",
"value": "XXXXXXXXXX"
}
],
"emailAddresses": [],
"postalAddresses": []
}

I also tried to do ImageSourceModule.fromNativeSource(contact.photo).toBase64String("png") and ImageSourceModule.fromNativeSource(contact.photo.ios).toBase64String("png") this will lead to an error setNativeSource is not UIImage