simple_update 1.0.0 simple_update: ^1.0.0 copied to clipboard
The simplest way to update app, support android for now.
simple_update #
The simplest way to update app, support android for now.
By default, the new version would be downloaded from avenge.cn, which is a simple Version-Management-System, welcome to try ^_^
You can set your own server to publish apps.
Getting Started #
-
Register for free
-
Create app & create version
https://avenge.cn/home/resources/apps/new https://avenge.cn/home/resources/versions/new
-
Install
dependencies: simple_update: ^1.0.0
Android
Add following provider referrence to AndroidManifest.xml inside
<application>
node.<provider android:name="sk.fourq.otaupdate.OtaUpdateFileProvider" android:authorities="${applicationId}.ota_update_provider" android:exported="false" android:grantUriPermissions="true"> <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/filepaths" /> </provider>
See AndroidManifest.xml in example
Also, create the file
android/src/main/res/xml/filepaths.xml
with following contents. This will allow plugin to access the downloads folder to start the update.<?xml version="1.0" encoding="utf-8"?> <paths xmlns:android="http://schemas.android.com/apk/res/android"> <external-path name="external_download" path="Download"/> </paths>
See filepaths.xml in example
Note Google Play Protect may in some cases cause problems with installation.
-
Usage
import 'package:simple_update/simple_update.dart'; ... RaisedButton( onPressed: () async { var updater = new SimpleUpdate( appId: 1, appKey: 'g4rehwe8fq4qe9rgh123', apiPrefix: 'http://avenge.cn/api'); var res = await updater.checkUpdate(Platform.Android); if (res == true) { var re = await showDialog<bool>( context: context, builder: (context) => AlertDialog( title: Text('New version'), content: Text('Install the new version?'), actions: [ FlatButton( onPressed: () => Navigator.pop(context), child: Text('Cancel')), FlatButton( onPressed: () => Navigator.pop(context, true), child: Text('Yes')), ], ), ); if (re == true) { var r = await updater.update(Platform.Android); if (r is Stream<Event>) { r.listen((event) { switch (event.status) { case Status.DOWNLOADING: print('downloading %${event.value}'); break; case Status.INSTALLING: print('installing'); break; case Status.ALREADY_RUNNING_ERROR: print('download is already running'); break; case Status.PERMISSION_NOT_GRANTED_ERROR: print( 'could not continue because of missing permissions'); break; case Status.INTERNAL_ERROR: case Status.DOWNLOAD_ERROR: case Status.CHECKSUM_ERROR: print('error ${event.value}'); } }); } } } else { print('no latest version'); } }, child: Text('Update'), ) ...
Build publish server #
The default value of [SimpleUpdate.apiPrefix] is 'https://avenge.cn/api', you can set your own server to publish apps.
var updater = SimpleUpdate(apiPrefix: 'your own server');
When request the latest version, it should send these parameters to remote server by GET method:
https://avenge.cn/api/latest?app_id=456&app_key=abc123&platform=0
platform: 0:android 1:ios 2:fuchsia 3:linux 4:windows 5:macOS
Then, the remote server will send back a json:
{
"code": 0,
"message": "success",
"data": {
"id": 123,
"app_id": 456,
"platform": 0,
"name": "1.0.1",
"number": 24,
"src": "https://avenge.cn/storage/apps/2020-07/app_name_1.0.1+24.apk",
"sha256": "sha256 of file",
"created_at": "2020-07-29 12:15:46"
}
}
If code is 0, it means success.
If something went wrong, it would be:
{
"code": -1,
"message": "something wrong ..."
}
All projects #
Plugins | Status | Description |
---|---|---|
simple_log | The simplest way to upload logs to remote server, support all platforms | |
simple_update | The simplest way to update your app, support android for now |