9

I'm currently building a site where, with one touch, you should be able to add a contact to your IPhone/Android Address book. The website is currently HTML5, but Javascript and/or PhP options could be implemented.

So is there a way that on the click of a link, the mobile device will open the Adress book already filled with the info I want it to have (Name, EMail Address, Street Address, Phone number).

I've looked everywhere to only find ways to program apps that would do the same thing. I want to make it from a webpage. Anywhere I can learn how to do this?

PS: Currently, I'm trying with everything in a .VCF file that could be downloaded on the click... this seems to lead me nowhere at the moment.

Mat Nadrofsky
  • 8,289
  • 8
  • 49
  • 73
Fredy31
  • 2,660
  • 6
  • 29
  • 54

5 Answers5

3

W3C defined Contacts API as a working draft but as far as I tested it's not supported in iOS devices(I have iPad with iOS4 and iPhone with iOS 5). You should test some android devices and tell us if they support Contacts API or not. That would be useful for future readers.

In case you have contacts api supported you can do this:

if(navigator.contacts){
   var mycontacts = [];
   navigator.contacts( ['emails.value', 'name', 'friends'],
                         function(contacts) { 
                           for(i in contacts) {

                               mycontacts.push(contacts[i]);

                         } );
}
Mohsen
  • 64,437
  • 34
  • 159
  • 186
2

To create a VCF; paste below code in notepad. Then change the contact information part. Save it as vcf.

BEGIN:VCARD
VERSION:3.0
N:Smith;John;;Mr.;
FN:John Smith
ORG:Acme Corporation
TITLE:Sales Manager
TEL;TYPE=WORK,VOICE:(123) 456-7890
ADR;TYPE=WORK:;;123 Main St.;Anytown;CA;12345;USA
EMAIL:john.smith@example.com
END:VCARD

Now upload this vcf file to a hosting server and get a link of that. Now this link can be share anywhare on the internet across the devices and platforms. once clicked on this link from a mobile phone. it will ask to save it as contact directly.

Jatin
  • 21
  • 1
  • i liked a lot. Ialso found this article on-line that exapnds on VCF https://www.techdim.com/what-is-a-vcf-file/ – CRAZYDATA Jul 03 '23 at 14:15
1

The first Idea i got was to use for Android (most Android-User, have a Google-Account) the Google-Contact-API.

bembii
  • 259
  • 2
  • 12
1

You might have to attack this from the device side of things instead. If that's what you end up doing try a cross-platform framework.

Not sure what your flexibility is, but for cross platform device integrated application I highly recommend PhoneGap. Plus, sounds like you've got some experience in HTML5 and CSS already. This could handle your contacts integration pretty easily across devices.

Mat Nadrofsky
  • 8,289
  • 8
  • 49
  • 73
0

I'm was searching for this too, and I found only this "near" solution:

  1. Make a QR for your contact card
  2. Use a link like:
    http://qrdroid.com/decode?q=[FULL-QR-IMAGE-URL] for it
  3. If the user has QR Droid installed, it will decode the URL.

a video here: http://www.youtube.com/watch?v=e-2D3uCV2bE

Personally I found that solution a bit buggy, this is safer:

  1. The user saves the QR image from the browser (long-click, save image)
  2. Open the image saved
  3. Click "Menu"->Share->Decode with QR Droid

a video here
http://www.youtube.com/watch?v=Ws99exsZEIs

CONS:
it's counter intuitive
you need android and QR droid installed
I don't know if it's possible with iphone, and other mobiles.

Enrique
  • 4,693
  • 5
  • 51
  • 71
  • I don't know if you answered the wrong question, but your answer doesn't make sense with the question. – Fredy31 Jan 28 '12 at 14:36
  • can you explain why? you are asking for a way to add contact info with a click from a webpage in HTML, and putting a QR code with the contact information can do that if you have qr droid installed – Enrique Jan 28 '12 at 15:49
  • 2
    that's exactly what I'm saying, you can add the contact info directly to your address books, contact list etc with a QR code generated for that. QR Droid detects that you have contact info in your QR code and let's you add that information directly to the contact list. You can create the QR with QR droid too. Video here: http://www.youtube.com/watch?v=BXCColkqV8I also here is an online generator for QR with contact information http://zxing.appspot.com/generator/ (test it with QR droid and you will see that you can add that information directly to your contact list) – Enrique Jan 28 '12 at 17:27