搜尋套件、儲存庫與 APP 分類

套件詳情v2.1.0

install_plugin

一個用於在 Android 上安裝 APK 的 Flutter 外掛;在 iOS 上使用 URL 跳轉到應用商店。

AndroidiOS
近 30 天下載
1.3萬
喜歡數
79
Pub 分數
150

安裝套件

flutter pub add install_plugin

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

install_plugin 是一個 Flutter 套件,可讓 Android 應用程式直接安裝 APK 檔案,促進無縫的應用程式更新或安裝。對於 iOS,它會透過提供的 URL 將使用者重新導向至 App Store,確保符合 Apple 的分發政策。專為應用程式更新情境設計,該套件簡化了傳遞新版本的過程,無需使用者手動從外部來源下載。此套件支援 Android 與 iOS 平台,提供跨平台的應用程式安裝工作流程管理解決方案。可透過 pub.dev 容易整合,並包含開源程式碼以確保透明度與自訂性。

適用情境

  • 應用自動更新功能
  • 直接在Android上安裝APK
  • 重定向 iOS 使用者至 App Store
  • 捆綁應用分發
  • 應用內更新提示
  • 離線應用安裝

主要特色

  • Android APK安裝
  • iOS 應用商店重定向
  • 跨平台支援
  • 透過 pub.dev 的簡單整合
  • 開源程式碼庫
  • 基於URL的iOS導航

適合對象

  • 開發自更新應用程式的開發者
  • 需要離線安裝的應用
  • 分發自定義 APK 的項目
  • 具有應用內更新邏輯的行動應用程式
  • 需要透明更新機制的團隊

使用建議

  • 需要 Android 權限以安裝 APK
  • iOS 僅支援 App Store 重新導向
  • APK安裝需要Android上的使用者權限
  • 不適合用於官方 App Store 提交
  • 僅限 Android 和 iOS 平台
  • 來自不可信APK來源的安全風險

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

install_plugin

Build Status pub package license

We use the install_plugin plugin to install apk for android; and using url to go to app store for iOS.

Usage

To use this plugin, add install_plugin as a dependency in your pubspec.yaml file. For example:

dependencies:
  install_plugin: '^2.1.0'

iOS

Your project need create with swift.

Android

You need to request permission for READ_EXTERNAL_STORAGE to read the apk file. You can handle the storage permission using flutter_permission_handler.

 <!-- read permissions for external storage -->
 <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

In Android version >= 8.0 , You need to request permission for REQUEST_INSTALL_PACKAGES to install the apk file

<!-- installation package permissions -->
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />

In Android version <= 6.0 , You need to request permission for WRITE_EXTERNAL_STORAGE to copy the apk from the app private location to the download directory

<!-- write permissions for external storage -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

Example

install apk from the internet

  _networkInstallApk() async {
    if (_progressValue != 0 && _progressValue < 1) {
      _showResMsg("Wait a moment, downloading");
      return;
    }

    _progressValue = 0.0;
    var appDocDir = await getTemporaryDirectory();
    String savePath = appDocDir.path + "/takeaway_phone_release_1.apk";
    String fileUrl =
        "https://s3.cn-north-1.amazonaws.com.cn/mtab.kezaihui.com/apk/takeaway_phone_release_1.apk";
    await Dio().download(fileUrl, savePath, onReceiveProgress: (count, total) {
      final value = count / total;
      if (_progressValue != value) {
        setState(() {
          if (_progressValue < 1.0) {
            _progressValue = count / total;
          } else {
            _progressValue = 0.0;
          }
        });
        print((_progressValue * 100).toStringAsFixed(0) + "%");
      }
    });

    final res = await InstallPlugin.install(savePath);
    _showResMsg(
        "install apk ${res['isSuccess'] == true ? 'success' : 'fail:${res['errorMessage'] ?? ''}'}");
  }

install apk from the local storage

  _localInstallApk() async {
    FilePickerResult? result = await FilePicker.platform.pickFiles();
    if (result != null) {
      final res = await InstallPlugin.install(result.files.single.path ?? '');
      _showResMsg(
          "install apk ${res['isSuccess'] == true ? 'success' : 'fail:${res['errorMessage'] ?? ''}'}");
    } else {
      // User canceled the picker
      _showResMsg("User canceled the picker apk");
    }
  }

Go to AppStore , example appStore url : https://itunes.apple.com/cn/app/%E5%86%8D%E6%83%A0%E5%90%88%E4%BC%99%E4%BA%BA/id1375433239?l=zh&ls=1&mt=8

  _gotoAppStore(String url) async {
    url = url.isEmpty ? _defaultUrl : url;
    final res = await InstallPlugin.install(url);
    _showResMsg(
        "go to appstroe ${res['isSuccess'] == true ? 'success' : 'fail:${res['errorMessage'] ?? ''}'}");
  }

所屬分類

原始碼儲存庫

使用此套件的專案