-1

Is there a way to prompt users to enable physical web (and therefore BlueTooth) with JavaScript in a similar way to APIs like getUserMedia()?

EDIT: I know this is relatively early stage tech and not widely supported, so the best option will probably be to help users turn this feature on at Settings > Privacy > Physical Web=on

Stan Bondi
  • 4,118
  • 3
  • 24
  • 35

2 Answers2

0

Actually, JS can create push notifications. The problem is that these notifications can't be prompted in the way the OP seems to want. What is possible (but likely not helpful) would be:

  1. Open web page
  2. Use JS to scan for beacons
  3. IF found, prompt the user to turn on Physical Web to find beacons easier in the future

I should also add that WebBluetooth V1 only lets you connect to a single device. V2 has a proposal (not yet finalized) that lets you scan. So everything here is still a bit early. However, these changes are on roadmaps so it's not total blue sky...

ScottJenson
  • 367
  • 1
  • 2
  • 10
  • Thanks ScottJenson, so at this stage, prompting the user to turn on Physical web would be showing them how to turn it on not showing a prompt to turn it on. If there were an API call it probably would be easily Googleable so safe to assume there isn't. – Stan Bondi Jun 13 '16 at 12:55
-1

No, there isn't. Javascript just can access LocalStorage on your disk, but not raise any prompt to any device on your machine.

MarioAraya
  • 336
  • 5
  • 10
  • js has access to "localstorage", but not to the filesystem. right idea, wrong verbiage. – I wrestled a bear once. Jun 10 '16 at 04:56
  • ...or to the hardware – I wrestled a bear once. Jun 10 '16 at 04:57
  • So in Android Chrome a user has to go into settings > Privacy > switch on Physical web (which uses bluetooth to detect Eddystone beacons) - just wondering if there is a JS call to prompt the user and make it a little easier to turn Physical web on. There is a Bluetooth API for Chrome (and possibly others) which requires an experimental flag be turned on. https://developer.mozilla.org/en-US/docs/Web/API/Web_Bluetooth_API – Stan Bondi Jun 10 '16 at 06:45
  • 1
    Short answer no: This is a privacy issue as Chrome doesn't want sites to turn something on without making it clear they are opting in. The Physical Web is meant to be a service that works across sites and needs to be turned on globally. It's a little bit like asking for a JS call to turn on Wifi. However, I appreciate the need to make this as easy as possible and if we're honest, it's frustrating people need to opt in, it *does* slow down adoption, but we can't rush this. It would erode user trust. – ScottJenson Jun 14 '16 at 14:41
  • Ahh didn't think about it like that :) There could be a way around that (sites being able to scope their physical web to a domain in the case of Eddystone-Url). Suppose the privacy issue around Physical Web is still actively being discussed. BTW add your privacy comment to the answer and I'll accept it – Stan Bondi Jun 14 '16 at 14:49