Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter automatically update application when new version is available

Tags:

flutter

dart

How can I implement auto-updating of my application when a new version is released without using Google Play Store? I'm using JSON to check the version.

like image 342
habatot haba Avatar asked Nov 12 '19 02:11

habatot haba


People also ask

Does Flutter support OTA updates?

Flutter plugin implementing OTA update. On Android it downloads the file (with progress reporting) and triggers app installation intent. ##Migrating to 4.0. 0+ This update solves many problems arising from using android download manager and saving to external downloads folder.


3 Answers

==== Update December 2021

new nice package, recommend this one https://pub.dev/packages/new_version

==== Actually, in June 2020, we have more possibilities with Flutter. Among them:

1. Make updates inside the app. Display two kinds of notifications if the app has the new version.

enter image description here

Plugin - https://pub.dev/packages/in_app_update (works only on Android, iOS doesn't support such functionality)

2. When a newer app version is available in the app store, a simple alert prompt widget or card is displayed.

enter image description here

Works Android & iOS. Plugin - https://pub.dev/packages/upgrader

3. Use Firebase in-app messaging. It gives flexibility in the messages and forms of notifications.

  • But a lot more boilerplate code and work.
  • But you can use it for other messages and notifications when your app is growing.

https://firebase.google.com/docs/in-app-messaging

4. Make it by yourself. Maybe even less code then in the case with Firebase messaging.

like image 120
awaik Avatar answered Oct 22 '22 12:10

awaik


It's not possible without using the google play store if you want an automatic update.

  • You need to handle the versioning yourself by hosting the apks somewhere (say github for example) and check if a new version exists and prompt the user whether they want to update the app.
  • Then download the new apk in the background. (You can use this package)
  • Then open the apk when it's done downloading using one of the methods mentioned here
  • Which will then prompt the user whether to allow installing apks from your app

A plugin exists if you want to do it using the play store. in_app_update Which wraps the android in-app update functionality s2

Their official example on github

If you also want an iOS solution, then it's not possible. You could redirect the user to the AppStore. Some more info on the distribution methods available for apple apps.

There is this method which might work if you have an enterprise license.

Whereas if you have a server running, have an endpoint to query the latest versions and another endpoint that allows users to download the apk.

Use something like github releases if you don't have a server.

like image 9
Phani Rithvij Avatar answered Oct 22 '22 12:10

Phani Rithvij


Maybe this help you

Backend backend = Backend.instance();
PackageInfo packageInfo = await PackageInfo.fromPlatform();
String packageName = packageInfo.packageName;

Response r;
try {

  r = await backend.io.get("https://play.google.com/store/apps/details?id=$packageName&hl=en");
  if(r.statusCode == 200){
    String data = r.data;

    String pat1 = 'Current Version</div><span class="htlgb"><div class="IQ1z0d"><span class="htlgb">';
    String pat2 = '</span>';

    int p1 = data.indexOf(pat1) + pat1.length;
    String f = data.substring(p1, data.length);
    int p2 = f.indexOf(pat2);

    String currentVersion = f.substring(0, p2);

    return currentVersion;
  }

  return null;

} catch (e) {

  errors = backend.interceptor.errors;

  return null;
}
like image 1
Bruno Camargos Avatar answered Oct 22 '22 10:10

Bruno Camargos