I'm working on a qr reader as part of a larger web application. Since the application is structured into several pages for each view, so not a single page app (SPA), I usually don't have any interaction from users on qr reader page because they've already done it on previous page by clicking "open reader" button. By calling navigator.vibrate(200)
a browser won't vibrate if user hasn't tapped a screen on the page that calls it. I want to use the vibration api as a signal of successfully found qr code.
As far as I know it's a general problem of any "old school" non SPA web app which utilizes functions restricted to user interaction. E.g. vibration, fullscreen, autoplay.
Is there any way around it except merging the page with the button and qr reader into one to not lose "user has interacted" between page reloads?
function qrCodeFoundCallback() {
if ('vibrate' in navigator) {
navigator.vibrate(200)
}
}
I expect a device which supports vibration api to always vibrate if a qr code is found even if user hasn't touch the screen after the page with camera finder has loaded.
Now the device vibrates only if the user randomly touched the screen but there's no reason for him/her to do it. The page contains camera finder and back button only.