pwa_install 套件讓 Flutter 應用程式能夠提示行動網頁使用者將其應用程式安裝為進階式 Web 應用程式(PWA)。它會偵測使用者是否透過行動裝置上的瀏覽器存取應用程式,並觸發原生安裝提示,提升使用者參與度與留存率。此套件與 Flutter 的 Web 平台無縫整合,支援多種作業系統,包含 Android、iOS、macOS、Windows 與 Linux。它利用瀏覽器層級的 PWA 功能,提供順暢的安裝體驗。
適用情境
提示網路使用者安裝PWA
提高移動瀏覽器上的應用參與度
改進基於 Web 的 Flutter 應用的留存率
透過 PWA 啟用離線存取
簡化跨平台部署
支援混合應用分發
主要特色
檢測行動網頁存取
觸發原生 PWA 安裝提示
跨多個平台運作
所需的設定最少
與 Flutter Web 結合
利用瀏覽器 PWA API
適合對象
開發面向網路的 Flutter 應用程式開發者
針對行動網頁使用者的團隊
旨在採用 PWA 的應用
需要低摩擦安裝的項目
跨平台網頁應用
混合應用策略
使用建議
PWA 功能需要 HTTPS
僅限支援 PWA 安裝提示的瀏覽器
可能不會在所有行動裝置上觸發
取決於使用者權限設定
不適用於非網頁平台
安裝行為因瀏覽器而異
原始 README
以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。
PWA Install
A small Flutter package that allows you to prompt mobile web users to install your Flutter app as a progressive web application (PWA) on demand.
A very basic example can be found here: PWA Install
The contents of this package are based on this article by Pete LePage (@petele)
Out-of-the-Box
As of release 1.20, all Flutter apps can be installed as PWAs. Combine this with the fact that all Chromium based browsers support PWAs and it becomes clear that designing your Flutter application for a mobile browser can be the most effective way of reaching a large audience.
When a Flutter app is opened in a supported browser, the user will see an install prompt like this:
Mobile Prompt
Web Prompt
This is awesome, but there's a caveat. The browser will only show the install prompt to users the first time they open your app. If the user refreshes the page or returns to the app while it's still in their browser history, the prompt will not be shown.
The PWA Install Package
With this package, you can prompt the user to install your app as a PWA on demand (e.g, on a button click). This package works by capturing the beforeinstallprompt event web browsers use to install PWAs. The event is captured when your app is launched and can be called anytime thereafter.
Setup
1. Update index.html
Add the following <script> tag to the body of web/index.html:
The following method can be called in main.dart before calling runApp(). PWAInstall() is instantiated as a singleton so you can use the class directly.