'vCard sent with Twilio not properly rendered in iOS
I'm trying to send a vCard to my iOS using curl
, but the vCard is not properly rendered in my iPhone.
EXCLAMATION_MARK='!'
curl -X POST https://api.twilio.com/2010-04-01/Accounts/<acc>/Messages.json \
--data-urlencode "Body=Test6$EXCLAMATION_MARK" \
--data-urlencode "MediaUrl=https://mighty-health-assets.s3.amazonaws.com/vcf/James.vcf" \
--data-urlencode "From=+14155926669" \
--data-urlencode "To=+14159108243" \
-u <acc>:<token>
I tried different Content-Type
and Content-Disposition
with my file.
For Content-Disposition:
inline; filename="James.vcf"
attachment; filename="James.vcf"
inline; name="James"
attachment; name="James"
For Content-Type:
text/vcard
text/x-vcard
text/vcard
text/vcard; charset=utf-8; name="fileName.vcf"
The result is always the same:
I'd like to have ideas on what to try next or if you already experienced the same issue before.
Solution 1:[1]
Troubleshooting problem
Turns out one of the configuration was correct, and the problem I was facing was a different one.
- When Twilio receives a file for the first time, it caches
- If you adjust the headers accordingly it won't impact the delivery of the VCF file, because it will use the cached version
- There is a way to overcome that
Twilio Caching
To remove the caching on your files or to set the appropriate cache policy, read: https://support.twilio.com/hc/en-us/articles/360024716314-How-Can-I-Change-the-Cache-Behavior-or-Message-Media-Files-
Troubleshooting I figured out that Twilio don't change cache based only on filename for VCF files, but by the file content itself, so you have to modify your file in order for it to clear the cache, not just the name.
Correct configuration
In order to get the file properly parsed by an iOS phone, you can use the same file format as attached https://mighty-health-assets.s3.amazonaws.com/vcf/James+Li.vcf
Headers
The contact card on iOS can only display the same text as of your file, so name your file with the same filename
header property on Content-Type
and it should work accordingly
Content-Disposition: inline; filename="<You file name>.vcf"
Content-Type: text/x-vcard
Cache-Control: no-cache
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |