渐进式 Web 应用程序与原生应用程序在 Android 上具有哪些功能,反之亦然 [英] What features do Progressive Web Apps have vs. native apps and vice-versa, on Android
问题描述
2015 年,Google 推出了一种新的 Android 网络应用开发方法:
硬件访问包括
- 地理定位 - 绝大多数浏览器都支持
- 通过 getUserMedia/Stream 和即将推出的 MediaStream Image Capture API
- 设备 振动
- screen 方向和加速度计访问,包括指南针和陀螺仪
- 电池状态
即将到来的硬件访问
这些功能正在或已经在某些浏览器中运行:
- 蓝牙通过网络蓝牙 API
- NFC
- 环境光传感器(在Firefox 48工作 +)
- 接近传感器(在Firefox 48工作 +)
- 加速度计、磁力计 和陀螺仪传感器访问
- 形状检测 API
另一个需要注意的重点是Origin Trials 框架(在 Chrome 中实施)使制造商能够公开和测试硬件(或软件)功能,而无需经过标准化过程.例如,手机制造商可以公开用于读取压力传感器值的 API,对其进行改进,然后将其提交给 W3C 以供考虑.
除了硬件访问之外,还有一些传统上由本机应用程序使用的软件功能,现在可用于网络应用程序.
PWA 也可以使用的传统原生功能
- 推送通知
- 离线工作
- 将图标添加到主屏幕
- 由于 WebAPKs - 渐进式 Web 应用程序现在可以打包到实际可安装的 Android 包中!
- 在 全屏
- 剪贴板访问
硬件加速的 2D/3D 图形,通过 HTML5 Canvas 或 WebGL - 检查一些 HTML5 Canvas 演示、WebGL 网站 或 three.js 库.Unity 跨平台游戏引擎的 2014 年基准比较了原生与 WebGL 渲染性能,以及 得出结论
<块引用>最重要的一点是,虽然 WebGL 在某些方面比本机代码慢得多,但总体而言,您已经可以获得非常不错的性能,而且这只会在未来变得更好."
- 在任何浏览器中阅读用户选择的文件
- 光滑、流畅的用户界面,带有 60fps 动画
这些功能涵盖了很多用例,现在许多流行的原生应用程序都可以重写为 PWA.以 Slack 为例.它的开源替代方案 Rocket.Chat 正在构建 PWA 版本.如需更多 PWA 演示,请参阅 https://pwa.rocks.
PWA 中的类似原生功能
- 处理意图 — 例如,将页面分享给另一个应用,或者成为共享目标,例如接收图像以设置为用户头像的 PWA 聊天应用程序
原生 Android 功能尚未提供给 PWA
- 访问指纹传感器(正在开发)
- 联系人、日历和浏览器书签访问(无法访问这些可被视为功能 由注重隐私的用户提供)
- 闹钟
- 电话功能 - 拦截短信或电话、发送短信/彩信、获取用户的电话号码、阅读语音邮件、在没有拨号器对话框的情况下拨打电话
- 对某些硬件功能和传感器的低级访问权限:手电筒、气压传感器
- 系统访问:任务管理、修改系统设置、日志
渐进式 Web 应用提供原生应用所缺乏的功能
- 可发现性 - 搜索引擎可以轻松找到渐进式网络应用中的内容,但像 StackOverflow 这样以内容为中心的原生应用不会在应用商店搜索结果中显示它确实提供访问权限的内容,例如pwa vs. native".对于像 Reddit 这样的社区来说,这是一个问题,它们无法将其众多子社区作为单独的应用程序"公开给应用商店.
- 可链接性 - 任何页面/屏幕都可以有直接链接,可以轻松共享
- 书签性 - 保存该链接以直接访问应用程序的视图
- 始终新鲜 - 无需通过应用商店推送更新
- 普遍访问 - 不受应用商店的约束 有时是任意政策 或(无意)地理限制
- 节省大量数据,这在互联网访问费用昂贵和/或速度缓慢的新兴市场中极为重要.例如,电子商务网站 Konga 通过迁移到首次加载将数据使用量减少了 92%一个 PWA.
- 分发阻力小 - 如果您的渐进式网络应用在线,则 Android(和其他移动设备)用户已经可以访问它.
- 65.5% 的美国智能手机用户不这样做t 每个月下载任何新应用
- PWA 无需去应用商店,搜索应用,点击安装,等待下载,然后打开应用.每一步都会失去 20% 的潜在用户.
最后一点:PWA 使用相同的代码库在桌面和大多数移动设备上运行.在桌面环境(ChromeOS,以及之后 Mac 和 Windows),它们的启动方式与其他应用相同,并在常规应用窗口(无浏览器标签)中运行.
In 2015 Google introduced a new approach for developing web apps for Android: progressive web apps. One can create an application that will look like a native application, will be able to use device's hardware like camera and accelerometers, receive push notifications, have a launcher icon, work in offline, store local data, etc.
On Android, what features do native apps provide that progressive web apps do not support, and vice versa.
TL;DR - As of Feb 2017, Progressive Web Apps are a sufficiently powerful platform that Twitter has moved all of their mobile web traffic to a React PWA.
As of August 2016, Progressive Web Apps actually offer more hardware access than commonly thought. Here's a screenshot of whatwebcando.today from my Chrome 52 stable on Android:
Hardware access includes
- geolocation - supported in the vast majority of browsers
- camera and microphone via the getUserMedia/Stream and the upcoming MediaStream Image Capture APIs
- device vibration
- screen orientation and accelerometer access, including compass and gyroscope
- battery status
Upcoming hardware access
These features are being implemented or already work in some browsers:
- Bluetooth via Web Bluetooth API
- NFC
- ambient light sensor (works in Firefox 48+)
- proximity sensor (works in Firefox 48+)
- accelerometer, magnetometer and gyroscope sensor access
- shape detection API
Another important point to note is that the Origin Trials Framework (implemented in Chrome) enables manufacturers to expose and test hardware (or software) capabilities without having to go through the standardization process. For example, a phone maker could expose an API for reading the values of a pressure sensor, refine it, then submit it for consideration to the W3C.
Besides hardware access, there are also software features traditionally employed by native apps that are now available to web apps.
Traditionally native features that PWAs can also use
- push notifications
- working offline
- adding an icon to the home screen
- appearing in the apps list thanks to WebAPKs - Progressive Web Apps can now be packaged into actual installable Android packages!
- launching in full-screen
- clipboard access
hardware-accelerated 2D/3D graphics via HTML5 Canvas or WebGL - check some of the HTML5 Canvas demos, WebGL sites or the three.js library. A 2014 benchmark of the Unity cross-platform game engine compared native vs. WebGL rendering performance, and concluded that
"The most important takeaway is, while there are still areas where WebGL is significantly slower than native code, overall you can get expect very decent performance already, and this can only get better in the future."
- reading user-selected files in any browser
- slick, smooth UIs with 60fps animations
These features cover a lot of use cases, and many popular native apps nowadays could be rewritten as PWAs. Take Slack, for example. Its open source alternative, Rocket.Chat, is building a PWA version. For more PWA demos, see https://pwa.rocks.
Native-like features coming to PWAs
- handling intents — for example, sharing a page to another app, or being the share target, e.g. a PWA chat app that receives an image to set as the user’s avatar
Native Android features not yet available to PWAs
- access to the fingerprint sensor (under development)
- contacts, calendar and browser bookmarks access (lack of access to these could be viewed as a feature by privacy-conscious users)
- alarms
- telephony features - intercept SMSes or calls, send SMS/MMS, get the user's phone number, read voice mail, make phone calls without the Dialer dialog
- low-level access to some hardware features and sensors: flashlight, atmospheric pressure sensor
- system access: task management, modifying system settings, logs
Progressive Web Apps offer features that native apps lack
- discoverability - content in progressive web apps can easily be found by search engines but a content-centric native app like StackOverflow won't show among app store search results for content that it does offer access to, such as "pwa vs. native". This is a problem for communities like Reddit, which can't expose their numerous sub-communities to the app store as individual "apps".
- linkability - any page/screen can have a direct link, which can be shared easily
- bookmarkability - save that link to access an app's view directly
- always fresh - no need to go through the app stores to push updates
- universal access - not subject by app stores sometimes arbitrary policies or (unintended) geographic restrictions
- large data savings, extremely important in emerging markets with expensive and/or slow Internet access. For example, e-commerce website Konga cut data usage by 92% for the first load by migrating to a PWA.
- low friction of distribution - if your progressive web app is online, it's already accessible for Android (and other mobile) users.
- 65.5% of US smartphone users don't download any new apps each month
- PWAs eliminate the need to go to the app store, search for the app, click Install, wait for the download, then open the app. Each of these steps loses 20% of the potential users.
Final note: PWAs run, with the same codebase, on the desktop as well as most mobile devices. On desktop environments (ChromeOS, and later Mac and Windows), they're launched in the same way as other apps, and run in a regular app window (no browser tab).
这篇关于渐进式 Web 应用程序与原生应用程序在 Android 上具有哪些功能,反之亦然的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!