패키지, 저장소 및 앱 카테고리 검색

패키지 상세v0.4.2

r_upgrade

응용 프로그램 업그레이드 및 설치를 위한 플러그인으로, Android 및 iOS를 지원합니다.

AndroidiOS
30일 다운로드
583
좋아요
141
Pub 점수
150

패키지 설치

flutter pub add r_upgrade

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

r_upgrade는 Android 및 iOS 플랫폼에서 앱 업그레이드와 설치를 가능하게 하는 Flutter 플러그인입니다. 업데이트 확인, 새 버전 다운로드, 그리고 원활한 설치를 위한 간단한 방법을 제공합니다. 신뢰할 수 있는 앱 내 업데이트 기능을 원하는 개발자를 위해 설계되었으며, 백그라운드 다운로드를 지원하고 플랫폼별 특수 사항을 처리합니다. pub.dev를 통해 쉽게 통합되며 GitHub를 통해 오픈소스 투명성으로 유지 관리됩니다. 외부 스토어에 의존하지 않고 자동 또는 수동 업데이트 워크플로우가 필요한 앱에 적합합니다.

사용 사례

  • 앱 내 업데이트 확인
  • 자동 앱 업그레이드
  • 사용자 정의 소스에서 수동 설치
  • 백그라운드 업데이트 다운로드
  • 크로스 플랫폼 업데이트 관리
  • 공식 스토어 외부에서의 앱 배포

주요 기능

  • Android 및 iOS를 지원합니다
  • pub.dev를 통한 간단한 통합
  • 백그라운드 다운로드 기능
  • 플랫폼별 업데이트 처리
  • GitHub의 오픈소스 코드
  • 간편한 업데이트 확인 및 설치

적합한 대상

  • 사용자 정의 업데이트 로직을 사용하여 앱을 개발하는 개발자
  • 오프라인 또는 직접 APK/IPA 설치가 필요한 앱
  • 크로스 플랫폼 업데이트 지원이 필요한 프로젝트
  • 내부 앱 배포를 관리하는 팀
  • Google Play/앱 스토어 의존성 회피 앱

고려 사항

  • 안드로이드에서 파일 액세스를 위해 적절한 권한이 필요합니다
  • iOS는 앱 설치를 위해 추가 구성이 필요합니다
  • App Store/Play Store에만 의존하는 프로덕션 앱에는 적합하지 않습니다
  • 사용자는 안드로이드에서 신뢰할 수 없는 소스에서의 설치를 활성화해야 합니다
  • 앱 바이너리 업데이트에 한정되며, 동적 콘텐츠는 포함되지 않음
  • 설치 후 앱 재시작 처리가 필요할 수 있습니다

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

r_upgrade

pub package

中文点此

Android and IOS upgrade plugin.

  • [✔] Jump link mode upgrade
  • [✔] Android Get user installed android stores.
  • [✔] Android Get version from android stores(only support GooglePlay、XiaoMi、Tencent)
  • [✔] Android 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

For the development of this plug-in, I haven't had a good meal for a long time. I hope you can click on the sponsor and give a little bit of money. Thank you!

List

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.Get android store list.
    void getAndroidStores() async {
       final stores = await RUpgrade.androidStores;
    }
2.Get version from android store.
    void getVersionName() async {
       final versionName = await RUpgrade.getVersionFromAndroidStore(AndroidStore.GOOGLE_PLAY);
    }
3. App upgrade from store.
    void upgradeFromAndroidStore(){
       bool isSuccess = await RUpgrade.upgradeFromAndroidStore(AndroidStore.GOOGLE_PLAY);
       print('${isSuccess?'jump success':'jump error'}');
    }
4. App upgrade from download link.

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

    <!--(if you want to upload google store,can not add this permission)-->
    <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
     <!--(if you want to use silent install,need to add this permission,and app is system app-->
    <uses-permission android:name="android.permission.INSTALL_PACKAGES" tools:ignore="ProtectedPermissions"/>

    <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.stream、install、cancel
  • 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.stream、install、cancel
    // [installType] downloaded finish will use install type to 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', installType: RUpgradeInstallType.normal,);
    }

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
  • use download id install
    void install() async {
      bool isSuccess=await RUpgrade.install(id);
    }
  • use file path install
    void installByPath(String path) async {
      bool isSuccess=await RUpgrade.installByPath(path);
     }
  • install type
/// [RUpgrade.upgradeWithId]、[RUpgrade.upgrade]、[RUpgrade.install]、[RUpgrade.installByPath]
enum RUpgradeInstallType {
  normal,//normal install
  silent,//silent install
  none,// not install
}
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,
                installType: RUpgradeInstallType.none,
                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.install(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
                 false
              );
        print(isSuccess);
    }
2.Get the last version form AppStore
    void getVersionFromAppStore() async {
        String versionName = await RUpgrade.getVersionFromAppStore(
                'your AppId',//such as:WeChat AppId:414478124
                false
               );
        print(versionName);
    }

LICENSE

Copyright 2021 rhymelph

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

카테고리

소스 저장소

이 패키지를 사용하는 프로젝트