All Projects → rhymelph → R_upgrade

rhymelph / R_upgrade

Licence: bsd-3-clause
🆙🚀 Flutter application upgrade / download Plug-in (with notice bar progress), supports full upgrade, hot update and incremental upgrade

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to R upgrade

Flutter reactive ble
Flutter library that handles BLE operations for multiple devices.
Stars: ✭ 155 (-12.43%)
Mutual labels:  flutter-plugin
Background locator
A Flutter plugin for updating location in background.
Stars: ✭ 162 (-8.47%)
Mutual labels:  flutter-plugin
Peardownloader.js
一个支持多协议、多源、混合P2P-CDN的下载器
Stars: ✭ 170 (-3.95%)
Mutual labels:  download
Tg Index
Python web app to index telegram channel and serve its files for download.
Stars: ✭ 157 (-11.3%)
Mutual labels:  download
Flickr Downloadr Gtk
A cross-platform desktop app, written in Mono that would download (all or selected) photos from your photostream in their selected size along with their description, title and tags.
Stars: ✭ 159 (-10.17%)
Mutual labels:  download
Youget
YouGet - YouTube Video/Playlist Downloader/Cutter - MP3 Converter
Stars: ✭ 169 (-4.52%)
Mutual labels:  download
Pccold
douyu斗鱼 自动化工具 主播上线通知 & 直播视频自动录制 & 弹幕抓取
Stars: ✭ 152 (-14.12%)
Mutual labels:  download
Opengit flutter
OpenGit基于Flutter的Github客户端,支持Android和iOS。项目中涉及到BloC、Redux、国际化、多主题以及Github相关信息的查看等。
Stars: ✭ 173 (-2.26%)
Mutual labels:  flutter-plugin
Gsy flutter demo
Flutter 不同于 GSYGithubAppFlutter 完整项目,本项目将逐步完善各种 Flutter 独立例子,方便新手学习上手和小问题方案解决。 目前开始逐步补全完善,主要提供一些有用或者有趣的例子,如果你也有好例子,欢迎提交 PR 。
Stars: ✭ 2,140 (+1109.04%)
Mutual labels:  flutter-plugin
Countrycodepicker
A flutter package for showing a country code selector.
Stars: ✭ 170 (-3.95%)
Mutual labels:  flutter-plugin
Downzemall
DownZemAll! is a download manager for Windows, MacOS and Linux
Stars: ✭ 157 (-11.3%)
Mutual labels:  download
Java Youtube Downloader
Simple, almost zero-dependency java parser for retrieving youtube video metadata
Stars: ✭ 160 (-9.6%)
Mutual labels:  download
Tiercel
简单易用、功能丰富的纯 Swift 下载框架
Stars: ✭ 2,241 (+1166.1%)
Mutual labels:  download
Flutter wordpress
Flutter WordPress API
Stars: ✭ 155 (-12.43%)
Mutual labels:  flutter-plugin
Muzonchik
iOS Music App that let you search, download and play music
Stars: ✭ 170 (-3.95%)
Mutual labels:  download
Demeter
Demeter is a tool for scraping the calibre web ui
Stars: ✭ 155 (-12.43%)
Mutual labels:  download
Macos Downloader
Command line tool for downloading macOS installers and beta updates
Stars: ✭ 162 (-8.47%)
Mutual labels:  download
Packages.flutter
👨‍💻 Plugins and packages for Flutter framework
Stars: ✭ 173 (-2.26%)
Mutual labels:  flutter-plugin
Ounotes
An Application built for students to access Notes , Question Papers , Syllabus and Resources for all Subjects of O.U (Osmania University) 📘👨‍🎓
Stars: ✭ 173 (-2.26%)
Mutual labels:  download
Flutter socket io
Socket IO supprt for flutter. Looking for contributors Swift and Java.
Stars: ✭ 170 (-3.95%)
Mutual labels:  flutter-plugin

r_upgrade

pub package

中文点此

Android and IOS upgrade plugin.

  • [✔] Jump link mode upgrade
  • [✔] Jump to store mode upgrade
  • [✔] Android Download APK using download link
    • [✔] Monitor download information
    • [✔] cancel/pause/continue download
    • [✔] Get download status according to ID
    • [✔] Install app according to ID
    • [✔] Get the last download ID (based on the version name and version number)
    • [✔] Modify the information displayed in the notification bar
  • [✔] Android hot upgrade
  • [✔] Android increment upgrade
  • [✔] IOS Jump to Appstore upgrade according to appid
  • [✔] IOS Get the current online version of Appstore according to appid

Getting Started

1. Use Plugin:

add this code in pubspec.yaml

dependencies:
  r_upgrade: last version

2. Upgrade from your website ( Android or IOS )

    void upgradeFromUrl()async{
        bool isSuccess =await RUpgrade.upgradeFromUrl(
                    'https://www.google.com',
                  );
        print(isSuccess);
    }

Android Platform

1. App upgrade from store.

    void upgradeFromAndroidStore(){
       bool isSuccess = await RUpgrade.upgradeFromAndroidStore(AndroidStore.GOOGLE_PLAY);
       print('${isSuccess?'jump success':'jump error'}');
    }

2. App upgrade from download link.

make sure your application had this permission and request dynamic permission.

    <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

1. Add Upgrade Download Listener

RUpgrade.stream.listen((DownloadInfo info){
  ///...
});

info:

param desc
(int) id download id
(int) max_length download max bytes length (bytes)
(int) current_length download current bytes length (bytes)
(double) percent download percent 0-100
(double) planTime download plan time /s (X.toStringAsFixed(0))
(String) path download file path
(double) speed download speed kb/s
(DownloadStatus) status download status
STATUS_PAUSED
STATUS_PENDING
STATUS_RUNNING
STATUS_SUCCESSFUL
STATUS_FAILED
STATUS_CANCEL

2. Upgrade your application

This upgrade have two part. useDownloadManager:

  • true: Use system DownloadManagerto download
    • advantage:Simple, use system.
    • Inferiority:can not use http download , can not click the notification pause downloading, can not pause and continue download by network status etc...
    • support: RUpgrade.streaminstallcancel
  • false: Use Service download(default use)
    • advantage:Power, support http/https download, support auto pause and continue download by network status etc..
    • Inferiority:No bugs found yet. If you find a bug, you are welcome to issue
    • support: RUpgrade.streaminstallcancel
    // [isAutoRequestInstall] downloaded finish will auto request install apk.
    // [apkName] apk name (such as `release.apk`)
    // [notificationVisibility] notification visibility.
    // [notificationStyle] download notification show style about content text, only support [useDownloadManager]==false.
    // [useDownloadManager] if true will use DownloadManager,false will use my service ,
    //         if true will no use [pause] , [upgradeWithId] , [getDownloadStatus] , [getLastUpgradedId] methods.
    // [upgradeFlavor] you can use [RUpgradeFlavor.normal] , [RUpgradeFlavor.hotUpgrade] , [RUpgradeFlavor.incrementUpgrade] flavor
    void upgrade() async {
      int id = await RUpgrade.upgrade(
                 'https://raw.githubusercontent.com/rhymelph/r_upgrade/master/apk/app-release.apk',
                 apkName: 'app-release.apk',isAutoRequestInstall: true);
    }

New upgraded flavor:(no support use DownloadManager)

enum RUpgradeFlavor {
  normal, // full upgrade
  hotUpgrade, // hot upgrade
  incrementUpgrade, // increment upgrade
}

3. Cancel Download

    void cancel() async {
      bool isSuccess=await RUpgrade.cancel(id);
    }

4. Install Apk

    void install() async {
      bool isSuccess=await RUpgrade.install(id);
    }

5. Pause Download

    void pause() async {
      bool isSuccess=await RUpgrade.pause(id);
    }

6. Continue Download

    void pause() async {
      bool isSuccess=await RUpgrade.upgradeWithId(id);
      /// return true.
      /// * if download status is [STATUS_PAUSED] or [STATUS_FAILED] or [STATUS_CANCEL], will restart running.
      /// * if download status is [STATUS_RUNNING] or [STATUS_PENDING], nothing happened.
      /// * if download status is [STATUS_SUCCESSFUL] , will install apk.
      ///
      /// return false.
      /// * if not found the id , will return [false].
    }

7. Get the last upgrade id

    void getLastUpgradeId() async {
     int id = await RUpgrade.getLastUpgradedId();
    }

8. Get the download status from id

    void getDownloadStatus()async{
    DownloadStatus status = await RUpgrade.getDownloadStatus(id);
   }

9. Increment Upgrade

  • 1.Download bsdiff to local.
  • 2.Prepare two installation packages, one is the one to be upgraded( old.apk ), an installation package that you need to update( new.apk )
  • 3.Switch to the 'bsdiff' directory downloaded above on the command line, and run the command./bsdiff old.apk new.apk increment.patch
  • 4.Put theincrement.patchUpload to server
  • 5.use RUpgrade.upgrade(...,upgradeFlavor:RUpgradeFlavor.incrementUpgrade)download file
  • 6.use RUpgrade.install(id) install apk.

The code is as follows:

    int id;
    void incrementUpgrade(){
        id = await RUpgrade.upgrade(
                'https://mydata-1252536312.cos.ap-guangzhou.myqcloud.com/r_upgrade.patch',
                fileName: 'r_upgrade.patch',
                useDownloadManager: false,
                isAutoRequestInstall: false,
                upgradeFlavor: RUpgradeFlavor.incrementUpgrade,
              );
    }

    void install(){
        try {
            await RUpgrade.install(id);
        } catch (e) {
            _state.currentState
                .showSnackBar(SnackBar(content: Text('failure!')));
        }
    }

10. Hot Upgrade

  • you can use this id to hot upgrade,but download file is zip. include three file [isolate_snapshot_data]、[kernel_blob.bin]、[vm_snapshot_data].Your can use flutter build bundle generate.
 flutter build bundle
  • generate file path form ./build/flutter_assets and packaged into zip.
|- AssetManifest.json
|- FontManifest.json
|- fonts
    |- ...
|- isolate_snapshot_data *
|- kernel-blob.bin       *
|- LICENSE
|- packages
    |- ...
|- vm_snapshot_data      *
  • use RUpgrade.upgrade(...,upgradeFlavor:RUpgradeFlavor.hotUpgrade)download file.
  • download complete you can use download id to hot upgrade
           bool isSuccess = await RUpgrade.hotUpgrade(id);
           if (isSuccess) {
              _state.currentState
                    .showSnackBar(SnackBar(content: Text('Hot update succeeded, exit the application after 3S, please enter again')));
                Future.delayed(Duration(seconds: 3)).then((_){
                  SystemNavigator.pop(animated: true);
                });
           }else{
              _state.currentState
                    .showSnackBar(SnackBar(content: Text('Hot update failed, please wait for update package download to complete')));
              }

At present, the hot update is still in the testing stage, only supporting the change of the flutter code, not supporting the resource file, etc. the author of the plug-in is not responsible for all the consequences caused by the hot update, and the user is responsible for it.

Android Platform Notification Bar

If you want to customize the content displayed in the download notification bar, you can do so, modify or add files project/android/app/main/res/values/r_upgrade_value.xml,add the following code

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="r_upgrade_download_speech">%.0f kb/s</string>
    <string name="r_upgrade_download_planTime">%.0fs left</string>
    <string name="r_upgrade_download_finish">Download finished</string>
    <string name="r_upgrade_download_paused">Download paused</string>
    <string name="r_upgrade_download_failed">Download failed</string>
</resources>

And then.When you use upgrade method,you should set the notificationStyle param.

/// Notification show style about content text
enum NotificationStyle {
  speechAndPlanTime, // 100kb/s 1s left
  planTimeAndSpeech, // 1s left 100kb/s
  speech,// 100kb/s
  planTime, // 1s left
  none, //
}

IOS Platform

1.Go to the AppStore Upgrade

    void upgradeFromAppStore() async {
        bool isSuccess =await RUpgrade.upgradeFromAppStore(
                 'your AppId',//such as:WeChat AppId:414478124
              );
        print(isSuccess);
    }

2.Get the last version form AppStore

    void getVersionFromAppStore() async {
        String versionName = await RUpgrade.getVersionFromAppStore(
                'your AppId',//such as:WeChat AppId:414478124
               );
        print(versionName);
    }
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].