Can a website (HTML5,JavaScript) access a mobile device's (android/iPhone) contact list, SDCard files

36,382

Solution 1

You can't access the mobile device file system through a website, it would be a major security problem. You might be able to steal all user files if you can access them through the browser. Hope this helps.

Solution 2

There was an attempt at the W3C to create a browser API to access contacts from the browser. This is often mentioned as one of the new HTML5 APIs.

However the attempt never became a real specification and never got implemented by any browser vendors. Now it is officially discontinued:

http://www.w3.org/TR/contacts-api/

Solution 3

At this point in time there is no way to access the internal APIs from Android, iOS and Windows Phone via a simple website. This also precludes you from accessing aspects such as the contact list because these are all only accessible via API calls.

Solutions that allow you to code phone apps or web apps in JavaScript or HTML5 and still grant access to APIs do so by utilizing a wrapper with calls back to the native code. But you can't call native code from an external source such as a website.

Solution 4

Chrome has since shipped their own version of a "Contact Picker" HTML5 API in Chrome 80: https://web.dev/contact-picker.

Chrome only: it is not a W3C Standard nor is it on the W3C Standards Track.

selectRecipientsButton.addEventListener('click', async () => {
  const contacts = await navigator.contacts.select(['name', 'email'], {multiple: true});

  if (!contacts.length) {
    // No contacts were selected in the picker.
    return;
  }

  // Use the names and e-mail addresses in |contacts| to populate the
  // recipients field in the website’s UI.
  populateRecipients(contacts);
});

Solution 5

https://developers.google.com/people/

You can't access Contacts by website stored on phone, but you can do it server side using People API. If user stored everything on the cloud - you win. Perhaps this is only way to provide native-like experience on your website

Share:
36,382

Related videos on Youtube

chaitanyad
Author by

chaitanyad

Android,Javascript,.NET... bring it on

Updated on June 15, 2020

Comments

  • chaitanyad
    chaitanyad almost 4 years

    Can a website (HTML5,JavaScript) access a mobile device's (android/iPhone)
    contact list, SDCard files? A website as in one opened in a browser not a phonegap application/webapp.

    • AJAY AVHAD
      AJAY AVHAD over 4 years
      Please refer this link for contact fetch
  • Nay
    Nay about 7 years
    You can access address book using Autofill feature of safari browser in iOS devices (but settings > safari > autofill > contact info must be turn on). And the name field in <input> must be "name, email, phone, tel, etc" to get autofill works properly. See below for screenshot
  • Manuel Manhart
    Manuel Manhart over 6 years
    The correct term would be: the user can upload files.
  • Andreas
    Andreas about 6 years
    bridgeit has now been shut down, due to the evolution of html5