问题
I am developing a button in my flask app, where you can click it and all the user's contact information will be displayed. It works on iphone and when you click it, the vcf file shows up with all your contact information with the option to save it to contacts.
This is the code:
vcf_file_path = 'static/Contacto.vcf'
with open(vcf_file_path , 'w') as file_vcard:
vcard = vobject.vCard()
o = vcard.add('fn')
o.value = rowes.pname
if rowr.img_url != 'default.png':
o = vcard.add('PHOTO;ENCODING=b;TYPE=image/jpeg')
o.type_param = 'PHOTO'
o.value = b64_image(rowr.img_url)
if rowes.pemail != "":
o = vcard.add('email')
o.type_param = 'INTERNET'
o.value = rowes.pemail
if rowes.pcellphone != "":
o = vcard.add('TEL')
o.type_param = 'Número Celular'
o.value = str(rowes.pcellphone)
And this the html button:
<a href="/{{vcf_file_path}}"><button class="mobileShow btn">Add to contacts<i class="fa fa-download" aria-hidden="true"></i></button></a>
.
Here there is one problem. While on iOS devices it works. With android devices it successfully downloads the vcf file, it shows up the contact app and the option to "save" it, but when I "save" it, then I go to the contacts app and the contact information is not there. It's like it has never been added. Also I try to import the contact from the system storage: the contact.vcf file exists but whenever I import it, nothing actually gets imported as the contact never shows up in the contact app. With IOS devices this works perfectly and the contact gets added easily. The problem is with android devices.
来源:https://stackoverflow.com/questions/62220050/contact-file-not-being-imported-properly-on-android-device