问题
When sending a vcard file on an SMS message via Twilio using the mediaUrl option, it shows up on the iPhone with "text 1" next to the file as if "text 1" is the file name.
I have tried renaming the vcard file, using example vcard files, etc. No matter what the files show up as "text 1".
I have tried on iPhone 8 and 10. I have tried bare bones VCF files and full featured ones from Outlook and even example ones online such as http://www.w3.org/2002/12/cal/vcard-examples/john-doe.vcf - No matter what, they show up on iPhone as "text 1".
What can I do to make this be either the phone number or a name?
Edit --- After the comment from @philnash, I was able to add a content-disposition header to the file which now comes back in the headers as follows:
Content-Disposition: attachment; name="John Doe"; filename="john-doe.vcf"
Here is a screenshot from Fiddler:
I also renamed the file to a unique name and tried again in case Twilio or anywhere along the way was caching the old file. The header is there but the message still shows "text 1" on the iPhone.
In case it had something to do with Azure blob storage. I also coded an ASP.Net MVC file action that returns the file with the content dispostion headers - it also shows as "text 1" on iPhone.
回答1:
I spent a long time troubleshooting this. I was almost going to give up. But then I sent my own contact through mms from my phone to a number controlled by twilio so I could see what headers Twilio was capturing when originating directly from an iphone. That's when I noticed this important header:
Content-Disposition: inline; filename="what-to-show.vcf"
The key here is the "inline" argument, "attachment" doesn't work. Then my stuff came over on iOS just as I wanted. ("what-to-show" instead of "text 1"). Perfect!
回答2:
No fix, just adding that this experience also is replicated on Android 9 (Pie). The only discrepancy with the above is that the file is "text_1".
回答3:
I tested this some as I was having the same issue. It appears once a Vcard has been sent, subsequent sends of the same Vcard result in text 1 being sent for the name of the Vcard. However, for sends to new recipients sends with the name. ...at least from my tests.
回答4:
Twilio developer evangelist here.
When Twilio provides the metadata for the MMS it does so based on the Content-Disposition
header it gets when requesting the media from the URL you provide. When there isn't one available, it gets set to something generic, like "text 1" in this instance.
To overcome this, you need to set the Content-Disposition
response header on the file you are serving. Within this header, you can declare a name and a filename. I haven't been able to test this (I'm not in the US, so can't receive the MMS from Twilio) but I would guess that the name is used, though I would test with filename too.
The header should look a bit like this:
Content-Disposition: inline; name="John Doe"; filename="john-doe.vcf"
来源:https://stackoverflow.com/questions/55387816/vcard-mms-file-name-is-always-text-1