How to automatically update a Flutter Mobile app to newer version when the application is not on play store or app store?
Solution 1
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.
Solution 2
ota_update(as mentioned by @Asmoun) looks good to me for this use case, alternative would be to download APK using something like flutter_downloader and start intent for install using android_intent.
Moreover for fetching latest version code or download URL, I suggest you use firebase_remote_config.
Solution 3
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
Solution 4
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.
Comments
-
Asmoun over 1 year
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 ?
-
Asmoun over 3 yearsSalem , thanks for the help can you refer to some links please for Flutter
-
Harsh Bhikadia over 3 yearsThis plugin looks good to me for this use case, alternative would be to download APK using something like flutter_downloader, and start initent for install using android_intent.
-
Harsh Bhikadia over 3 yearsBut that is too much work!! Just use the plugin you mentioned, if it functions well.
-
Asmoun over 3 yearsthanks for the help but i'm looking for a solution for Flutter app
-
Harsh Bhikadia over 3 years@Asmoun Let me know if you need some code sample. The readme instructions of those plugins look self-explanatory to me!
-
ff .n about 3 yearshi , how to get sha256checksum?
-
Asmoun about 3 years@ff.n hello, based on the documentation i think it is optional so you can pass it , if you found the answer useful can you please upvote the post and answer
-
Sunpreet Singh almost 3 yearsyes it would be great if you can share the code sample. I need to do this in my project, but not sure exactly what all I need to do. If I use ota_update and give the link to the apk file on my server, shouldn't be it good enough? What is the need of flutter_downloader and other packages that you mentioned. Thanks in advance
-
cwhisperer over 2 yearsI use ota_update:4.0.1 and it works like a charm for downloading and installing a new .apk from hosted server
-
vishalknishad about 2 yearsGreat, thanks..