1
I have a mobile app accessing via browser, this has a button with phone number. I would like when the user clicks if this button the number was saved in the phonebook.
Thank you
1
I have a mobile app accessing via browser, this has a button with phone number. I would like when the user clicks if this button the number was saved in the phonebook.
Thank you
4
This is not possible, even for security reasons. Suppose it was possible - in this case, a page could overwrite the user’s contacts.
On the other hand, you can turn a phone number into a link. In this case, the user can click on the link that the phone will appear in the call application. Just use something like:
<a href="tel:+55 99 10101010">Número de telefone</a>
Test here: https://jsfiddle.net/ycmyu86b/
With the number in the phone app, the user can then add it to the contacts, or call the number. But the decision of what to do will always stay with the user.
EDITED: @Sergio made an interesting comment, suggesting using vCards. Although the contact will not be added automatically, vCard really has many advantages: it gives to suggest the contact name, add more information etc. And it is possible to do it without even needing a server! Consider the vCard below:
BEGIN:VCARD
VERSION:2.1
N: brandizzi
FN: brandizzi
TEL;WORK;VOICE: +55 (66) 7788 9910
END:VCARD
We can encode it to put it in a URL (for example, with encodeURI()
):
"BEGIN:VCARD%0AVERSION:2.1%0AN:%20brandizzi%0AFN:%20brandizzi%0ATEL;WORK;VOICE:%20+55%20(66)%207788%209910%0AEND:VCARD"
Now, just use this encoded version in a data URL
<a
href="data:text/vcard,BEGIN:VCARD%0AVERSION:2.1%0AN:%20brandizzi%0AFN:%20brandizzi%0ATEL;WORK;VOICE:%20+55%20(66)%207788%209910%0AEND:VCARD"
download="meucontato.vcf">
Link para contato
</a>
Personally, I like the URL for the phone because I, as a user, almost never want to add a contact to my calendar, I just want to call. Now, I suspect that vCard works better for what the OP wants.
But it would not be possible to make the webapp return a download of a vcf
? http://stackoverflow.com/q/1773876/2256325
Thank you @brandizzi o <a href="">
helping.
@Sergio is possible, but again the user will have to choose whether or not to add the contact. It is not possible to do it automatically via script. On the other hand, vCard really has an advantage: it is possible to pass more information through it, in addition to the number. It is not necessary to generate on the server, can do via Javascript. At least I managed to do, in a test here. I will complement my answer.
@brandizzi if you have time for an example with vCard would be excellent. However it seems that your help has already solved the problem :)
Browser other questions tagged javascript html5 mobile
You are not signed in. Login or sign up in order to post.
Can you be any clearer? you are making or made an APP that has browser functionality and when you click on a phone number it stores in your contacts?
– Sergio
Sergio and a mobile app, accessing through the browser. There is a button with the telephone number, when the user clicks on this number he saves in the phonebook.
– kadu pereira