Git Product home page Git Product logo

flutter_update_app's Introduction

Update the app, pass in the updated address, and update the app. 更新app, 传入更新的地址, 进行app更新

The Android part is implemented using DownloadManager. If the file has been downloaded, install it directly. Android部分使用DownloadManager实现.若文件已下载, 则直接安装.

The Ios section does not support external updates, skip the App Store. Ios部分不支持外部更新, 跳转App Store.

Experience demo(体验Demo)

download apk(下载APK)

screen

How to use(如何使用)

import 'package:update_app/update_app.dart';

/// Download the app and update
///
/// appleId: This is the app id of the app store, used to jump to the app store
/// url: This is the URL to download the apk file
/// title: Android download the title displayed in the notification bar, generally use the file name, or like this `update version 1.6`
/// description: Android download the description displayed in the notification bar, similar to the subtitle
///
/// @return `-1` -> `download failed`, `0` -> `There is a current apk locally, and the download is successful`, other (int) -> `downloadId`
var downloadId = await
UpdateApp.updateApp(url: "apkPath", appleId:"375380948", title:"通知标题", description:"通知描述");

/// Query apk download progress
///
/// downloadId: [updateApp] 返回的downloadId
///
/// @return [DownloadProcess]
/// current: Currently downloaded length
/// count: Total length
/// status: [ProcessState]
///         STATUS_PENDING: [ProcessState.STATUS_PENDING](https://developer.android.com/reference/android/app/DownloadManager#STATUS_PENDING)
///         STATUS_RUNNING: [ProcessState.STATUS_RUNNING](https://developer.android.com/reference/android/app/DownloadManager#STATUS_RUNNING)
///         STATUS_PAUSED: [ProcessState.STATUS_PAUSED](https://developer.android.com/reference/android/app/DownloadManager#STATUS_PAUSED)
///         STATUS_SUCCESSFUL: [ProcessState.STATUS_SUCCESSFUL](https://developer.android.com/reference/android/app/DownloadManager#STATUS_SUCCESSFUL)
///         STATUS_FAILED: [ProcessState.STATUS_FAILED](https://developer.android.com/reference/android/app/DownloadManager#STATUS_FAILED)
var process = await
UpdateApp.downloadProcess(downloadId: downloadId);

Document

UpdateApp.updateApp

Params

appleId - This is the app id of the app store, used to jump to the app store
url - This is the URL to download the apk file
title - Android download the title displayed in the notification bar, generally use the file name description - Android download the description displayed in the notification bar, similar to the subtitle

Return

-1 -> download failed
0 -> There is a current apk locally, and the download is successful
other (int) -> downloadId

UpdateApp.downloadProcess

Params

downloadId - [updateApp] 返回的downloadId

Return

[DownloadProcess]
current: Currently downloaded length
count: Total length
status: [ProcessState]
STATUS_PENDING: ProcessState.STATUS_PENDING
STATUS_RUNNING: ProcessState.STATUS_RUNNING
STATUS_PAUSED: ProcessState.STATUS_PAUSED
STATUS_SUCCESSFUL: ProcessState.STATUS_SUCCESSFUL
STATUS_FAILED: ProcessState.STATUS_FAILED

Features(特点)

Android part(Android部分)

  1. Download using DownloadManager
    使用DownloadManager进行下载
  2. Monitor download completion broadcast
    监听下载完成广播
  3. Adapt Android 6.0 Runtime Permissions Files are stored in the app directory, no need to apply for runtime permissions
    适配Android 6.0运行时权限 文件存储在app目录, 不需要申请运行时权限
  4. Adapt Android 7.0FileProvider
    适配Android 7.0FileProvider
  5. Adapt Android 8.0 installation permissions
    适配Android 8.0安装权限

Adapt [Android 9.0 Network Security Configuration] (https://developer.android.com/training/articles/security-config)
适配Android 9.0网络安全配置

IOS section(IOS部分)

  1. Jump to the app store 跳转应用商店

flutter_update_app's People

Contributors

kkenwv avatar mofada avatar randomqqn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

flutter_update_app's Issues

对于未引入kotlin的项目报错

  • Where:
    Build file '/Users/yhz/Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/update_app-0.1.2/android/build.gradle' line: 25

  • What went wrong:
    A problem occurred evaluating project ':update_app'.

Plugin with id 'kotlin-android' not found.

运行报错了

/Users/weiwei/Documents/byapp/android/app/src/debug/AndroidManifest.xml:51:13-64 Error:
Attribute provider#androidx.core.content.FileProvider@authorities value=(com.huaronghz.hs.fileprovider) from AndroidManifest.xml:51:13-64
is also present at [:update_app] AndroidManifest.xml:22:13-66 value=(com.huarong.hs.updateprovider).
Suggestion: add 'tools:replace="android:authorities"' to element at AndroidManifest.xml to override.
/Users/weiwei/Documents/byapp/android/app/src/debug/AndroidManifest.xml:56:13-47 Error:
Attribute meta-data#android.support.FILE_PROVIDER_PATHS@resource value=(@xml/file_paths) from AndroidManifest.xml:56:13-47
is also present at [:update_app] AndroidManifest.xml:27:17-52 value=(@xml/update_path).
Suggestion: add 'tools:replace="android:resource"' to element at AndroidManifest.xml to override.

FAILURE: Build failed with an exception.

Null safety

Would it be possible to add null safety support to make this dependency work with the newest version of dart?

监听下载完成广播

我点击下载后,就顶部通知栏有下载的图标。
但下载完成后,不会自动打开文件。
而在调用下载时,无法获取到储存的位置。
我要如何在下载完后,打开呢

Unhandled Exception: MissingPluginException

I got the following error while using the plugin:

E/flutter ( 8497): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: MissingPluginException(No implementation found for method updateApp on channel cn.mofada.cn/update_app)
E/flutter ( 8497): #0      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:319:7)
E/flutter ( 8497): <asynchronous suspension>
E/flutter ( 8497): #1      UpdateApp.updateApp (package:update_app/update_app.dart:17:33)
E/flutter ( 8497): #2      MyHomePage._install (package:appselfupdatetest/main.dart:46:17)
E/flutter ( 8497): <asynchronous suspension>
E/flutter ( 8497): #3      _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:706:14)
E/flutter ( 8497): #4      _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:789:36)
E/flutter ( 8497): #5      GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:182:24)
E/flutter ( 8497): #6      TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:486:11)
E/flutter ( 8497): #7      BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:264:5)
E/flutter ( 8497): #8      BaseTapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:199:7)
E/flutter ( 8497): #9      PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:467:9)
E/flutter ( 8497): #10     PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:76:12)
E/flutter ( 8497): #11     PointerRouter._dispatchEventToRoutes.<anonymous closure> (package:flutter/src/gestures/pointer_router.dart:117:9)
E/flutter ( 8497): #12     _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:379:8)
E/flutter ( 8497): #13     PointerRouter._dispatchEventToRoutes (package:flutter/src/gestures/pointer_router.dart:115:18)
E/flutter ( 8497): #14     PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:101:7)
E/flutter ( 8497): #15     GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:218:19)
E/flutter ( 8497): #16     GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:198:22)
E/flutter ( 8497): #17     GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:156:7)
E/flutter ( 8497): #18     GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:102:7)
E/flutter ( 8497): #19     GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:86:7)
E/flutter ( 8497): #20     _rootRunUnary (dart:async/zone.dart:1138:13)
E/flutter ( 8497): #21     _CustomZone.runUnary (dart:async/zone.dart:1031:19)
E/flutter ( 8497): #22     _CustomZone.runUnaryGuarded (dart:async/zone.dart:933:7)
E/flutter ( 8497): #23     _invoke1 (dart:ui/hooks.dart:273:10)
E/flutter ( 8497): #24     _dispatchPointerDataPacket (dart:ui/hooks.dart:182:5)
E/flutter ( 8497): 

I've used the same code as it is in the example:

UpdateApp.updateApp(url: filePath, appleId:"375380948",title:"Title",description:"Description");

I get the filePath from the FilePicker dependency and also checked the path. How do I resolve this issue? At this point, the plugin isn't usable at all because it crashes instantly.

[Feature] Desktop support

It would be great to add desktop support to this plugin. Implemented could it be in a similar way as the android update process. A download url is passed and the executable gets downloaded and opened/installed afterwards. Is something like this planned or in development?

插件消失

现在packages get或者packages update之后,在Android模块下路径为app/src/main/java/io/flutter/plugins的GeneratedPluginRegistrant系统生成类中找不到update app相关的字段,自然也能说明此插件失效。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.