Save number to phonebook? [closed]

1

I have a mobile app accessing via browser, this one has a button with a phone number. I would like that when the user clicks on this button the number would be saved in the phonebook.

Thank you

    
asked by anonymous 01.08.2016 / 14:54

1 answer

4

This is not possible, even for security reasons. Suppose it were 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 calls application. Just use something like:

<a href="tel:+55 99 10101010">Número de telefone</a>

Test here: link

With the number in the phone application, 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.

EDIT : @Sergio made an interesting comment suggesting using vCards. Although the contact will not be added automatically, the vCard does have many advantages: you can suggest the name of the contact, add more information, etc. And you can 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 version encoded 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 to 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 the vCard works best for what the OP wants.

    
01.08.2016 / 15:09