How to automatically update a Flutter Mobile app to newer version when the application is not on play store or app store?

Viewed 13109

let's say i have a Flutter APK hosted on my website where users can download and install , what i'm interested to know is how possible that the application can check for newer version when the app lunches and if true a progress bar appears showing the automatic updating of the application from the server (not play store or app store) ? .
here is a company that do exactly the mentioned above meaning :

  • download the apk from there server
  • whenever a new version is released the app will update from their server

any ideas how to achieve this ?

4 Answers

i found this package ota_update 2.4.1,looks very promising for updating a Flutter from a remote hosted Apk here is an exmple :

   // IMPORT PACKAGE
    import 'package:ota_update/ota_update.dart';
    
      // RUN OTA UPDATE 
      // START LISTENING FOR DOWNLOAD PROGRESS REPORTING EVENTS
      try {
          //LINK CONTAINS APK OF FLUTTER HELLO WORLD FROM FLUTTER SDK EXAMPLES
          OtaUpdate()
              .execute(
            'https://internal1.4q.sk/flutter_hello_world.apk',
            // OPTIONAL
            destinationFilename: 'flutter_hello_world.apk',
            //OPTIONAL, ANDROID ONLY - ABILITY TO VALIDATE CHECKSUM OF FILE:
            sha256checksum: "d6da28451a1e15cf7a75f2c3f151befad3b80ad0bb232ab15c20897e54f21478",
          ).listen(
            (OtaEvent event) {
              setState(() => currentEvent = event);
            },
          );
      } catch (e) {
          print('Failed to make OTA update. Details: $e');
      }

any other proposed solutions are welcome.

You can write a service on the server-side that check the current version with the old version in the splash screen. First, you must send the current version to the server and check version uploading with the old version uploaded then if there are a new version return alert and apk for download

If you need this for Android only, you could use the in_app_update library.

If you need functionality for iOS too, the above library recommends upgrader that does something similar but not the same.

Related