2

This web application designed for mobile devices is written in javascript/backbone with node.js/postgres on the server side. On the client side, I have a function that takes the data from a contact and parses it into a .vcf ready string. From what I understand, client side javascript doesn't grant access to the file system, and I will probably have to do the actual saving in node. I haven't started on that part yet because I'm concerned that the phones won't allow me to do what I want to do.

I would like to have a button that prompts the user if they'd like to add the contact to their device's contacts. Is this even possible from a web app? I'd appreciate it if someone could point me in the right direction.

moka
  • 22,846
  • 4
  • 51
  • 67
Mike
  • 21
  • 1
  • 2
  • you can download a cal or contact file to trigger the add contact intent. there is a writeup on this: http://mobicontact.info/iphone/download-contact-from-web-page/ , but it uses php. i could not find a js-only version, but you can use dataURLs to "download" a "file" created in javascript, and i'm sure js is up to the rest of PHP's work in that example. – dandavis Jul 08 '13 at 18:02

1 Answers1

2

There is no way of accessing phone contacts from the web due to huge security problems such functionality can lead to.

Although there is way to access contacts through native applications. You might consider looking into something like PhoneGap that is just a native wrapper around your web application, and it have ability to allow user to share contacts with your application > JS. Then you will be able to modify contacts, add/remove if such permissions are granted to your app.

And check out this documentation from PhoneGap that has some nice functionality that does exactly what you need: http://docs.phonegap.com/en/2.5.0/cordova_contacts_contacts.md.html

For more info, check out this brilliant answer: Get users number from iPhone using HTML5/jQuery

Community
  • 1
  • 1
moka
  • 22,846
  • 4
  • 51
  • 67
  • Exporting - is a process of extracting data. Importing is a process of implementing data from the outside source into common format to target. The node.js should not be there at all then, as well as your title is misleading. And still, in order to import contacts - you need access to contacts via sort of API, and suggestions from answer still apply perfectly. I've updated answer above. – moka Jul 09 '13 at 08:48