且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

手机屏幕关闭时正在运行HTML5网站吗?

更新时间:2023-02-26 21:27:00

尽管我们希望对此有所改变,但不幸的是,它没有改变.

关于PWA GeoLocatoin API的 Google文章日期为2018年1月的日期清楚地表明,此API仅在页面打开时有效".

为什么(我认为)不可用?考虑到用户的隐私,这是有道理的.想一想我们访问的大量wep页面,以及有多少我们意外地倾向于五个许可或者我们打算给予一段时间(直到我们完成一些交易/预订).当前,我们无法像在本机/混合应用程序中一样检查并赋予更改选项的权利,无法检查在浏览器中授予网站的所有位置权限.

当将PWA安装到主屏幕时,我们可以期望它具有跟踪选项,这样用户就可以使用本机应用程序(例如权限处理).

故事的结尾,我们还没到那儿!!

替代选项:虽然您可以使用 navigator.geolocation.watchPosition 来跟踪用户积极使用该应用程序时的情况,但是您可以通过单独安装该应用程序来补充该应用程序(本机)Android服务,用于将用户位置更新到您的后端服务器,直到PWA天真支持为止.

Basically, my question is the same than this topic but it's now 2018. So, how can I still have ECMAScript executed on my phone (to send geolocation position) even if it is asleep? We now have Open Web Apps and Progressive Web Apps (PWA) with service workers, even Apple is jumping in, I'm sure there are ways to do that.

While we can hope that things should've changed on this, unfortunately, it has not.

This article from Google on PWA GeoLocatoin API dated Jan-2018 says clearly that this API works "only while the page is open".

Why not available yet (in my opinion)? Thinking of users privacy, it makes sense. Think of tons of wep pages we visit and for how many we tend to five permission accidentally or we intend to give for a while(until we finish some transaction/booking). Currently there is no way for us to go and check on all location permissions that we've given to web sites in a browser, like we do for Native/Hybrid apps and having option to change it.

We can expect to have tracking option for PWA when it is installed to home screen, where native app like permission handling will be possible to user.

End of the story, we are not there yet!!

Alternate option: While you can use navigator.geolocation.watchPosition to track the user when he is actively using the app, You can complement your app with a separately installed (Native) Android service to update the users location to your back end server, till PWA supports naively.