simple_update 1.0.0 copy "simple_update: ^1.0.0" to clipboard
simple_update: ^1.0.0 copied to clipboard

outdated

The simplest way to update app, support android for now.

Language: English | 中文

simple_update #

Pub Version Platform

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 #

  1. Register for free

    https://avenge.cn/register

  2. Create app & create version

    https://avenge.cn/home/resources/apps/new https://avenge.cn/home/resources/versions/new

  3. 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.

  4. 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 Pub Version The simplest way to upload logs to remote server, support all platforms
simple_update Pub Version The simplest way to update your app, support android for now
4
likes
20
pub points
0%
popularity

Publisher

verified publisheravenge.app

The simplest way to update app, support android for now.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter, http, ota_update, package_info

More

Packages that depend on simple_update