手机屏幕关闭时正在运行HTML5网站吗? [英] HTML5 website running while phone screen is off?

查看:122
本文介绍了手机屏幕关闭时正在运行HTML5网站吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上,我的问题与此主题,但现在是2018年.那么,即使我已经睡着了,我如何仍可以在手机上执行ECMAScript(以发送地理位置信息)?现在,我们已经有了带有服务人员的Open Web Apps和Progressive Web Apps(PWA),即使Apple正在加入,我也相信有办法做到这一点.

解决方案

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

关于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.

这篇关于手机屏幕关闭时正在运行HTML5网站吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆