Aus öffentlichen Paketdaten erstellte Orientierung.
r_upgrade ist ein Flutter-Plugin, das die Aktualisierung und Installation von Apps auf Android- und iOS-Plattformen ermöglicht. Es bietet eine einfache Möglichkeit, Updates zu überprüfen, neue Versionen herunterzuladen und sie nahtlos zu installieren. Für Entwickler, die zuverlässige In-App-Aktualisierungsfunktionen suchen, unterstützt es Hintergrunddownloads und berücksichtigt plattformspezifische Besonderheiten. Das Plugin lässt sich problemlos über pub.dev integrieren und wird durch GitHub mit Transparenz im Open-Source-Bereich gepflegt. Ideal für Apps, die automatische oder manuelle Aktualisierungsworkflows benötigen, ohne auf externe Stores angewiesen zu sein.
Anwendungsfälle
In-App-Update-Überprüfungen
Automatische App-Updates
Manuelle Installation von benutzerdefinierten Quellen
Hintergrund-Update-Downloads
Plattformübergreifendes Update-Management
App-Verteilung außerhalb offizieller Stores
Hauptmerkmale
Unterstützt Android und iOS
Einfache Integration über pub.dev
Hintergrund-Download-Funktion
plattformspezifische Update-Verwaltung
Open-Source-Code auf GitHub
Einfache Aktualisierungsüberprüfung und -installation
Geeignet für
Entwickler, die Apps mit benutzerdefinierter Aktualisierungslogik erstellen
Apps, die eine Offline- oder direkte APK/IPA-Installation erfordern
Projekte, die Unterstützung für plattformübergreifende Updates benötigen
Teams, die die interne App-Verteilung verwalten
Apps, die von Google Play/App Store-Abhängigkeiten unabhängig sind
Hinweise
Erforderliche Berechtigungen für den Dateizugriff unter Android
iOS erfordert zusätzliche Konfiguration für die App-Installation
Nicht geeignet für Produktions-Apps, die ausschließlich auf App Store/Play Store angewiesen sind
Der Benutzer muss die Installation von unbekannten Quellen auf Android aktivieren
Beschränkt auf App-Binäraktualisierungen, nicht auf dynamische Inhalte
Nach der Installation kann möglicherweise die Behandlung eines App-Neustarts erforderlich sein
Original-README
Originaler README-Schnappschuss aus dem verknüpften Quell-Repository. Aktuelle Inhalte finden Sie im Repository.
[✔] 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!
make sure your application had this permission and request dynamic permission.
<!--(if you want to upload google store,can not add this permission)--><uses-permissionandroid:name="android.permission.REQUEST_INSTALL_PACKAGES" /><!--(if you want to use silent install,need to add this permission,and app is system app--><uses-permissionandroid:name="android.permission.INSTALL_PACKAGES"tools:ignore="ProtectedPermissions"/><uses-permissionandroid:name="android.permission.INTERNET"/><uses-permissionandroid:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
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] flavorvoidupgrade() async {
int id = awaitRUpgrade.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)
enumRUpgradeFlavor {
normal, // full upgrade
hotUpgrade, // hot upgrade
incrementUpgrade, // increment upgrade
}
voidpause() async {
bool isSuccess=awaitRUpgrade.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
voidgetLastUpgradeId() async {
int id = awaitRUpgrade.getLastUpgradedId();
}
8. Get the download status from id
voidgetDownloadStatus()async{
DownloadStatus status = awaitRUpgrade.getDownloadStatus(id);
}
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.
use RUpgrade.upgrade(...,upgradeFlavor:RUpgradeFlavor.hotUpgrade)download file.
download complete you can use download id to hot upgrade
bool isSuccess = awaitRUpgrade.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
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.