Is there a way to get the previous version of an app or know if it has been updated or downloaded? - flutter

I was trying to build a feature announcement where I can tell the users that there is a new feature available on my flutter app.
The problem is that I don’t want to show this if someone just downloaded the app, since they are new users anyway, I just want to show that to users that were using the app before.
Is there a way to know previous versions of the app that were installed or if the app was updated vs just downloaded?

First of All there is package to find your app current version number and build number, I have used this personally with the backend to show some new features to our new users.
Add this to your package's pubspec.yaml file:
package_info: ^0.4.0+16
Now import the statement into your dart file
import 'package:package_info/package_info.dart';
And use this if your method is marked as async:
PackageInfo packageInfo = await PackageInfo.fromPlatform();
String appName = packageInfo.appName;
String packageName = packageInfo.packageName;
String version = packageInfo.version;
String buildNumber = packageInfo.buildNumber;
Now, What you have to do is that send the current version number in your API,
And have a Current Version Value stored in backend, To check for the Versions you are sending in the API's and Compare them to show new Features,
Like Say If I am old User, So My APP Version number is 1 and API's is sending 1 in the backend too.
But If I am new User then, My APP version is number greater than 1 and API's is sending version number greater than 1, And I can see the update in the app if My Version number is greater than 1 as a new User.
Click Here For More Reference to use the Package
Sorry For bad English

Related

Firebase 9 & Flutter: How to initializeApp?

I am desperately trying to figure out how to initializeApp with Flutter (not React Native).
I know about the functions to use, but I can not find the firebaseConfig I need to pass into the function.
And no matter what I search for, every resources references to React Native, like as if nobody codes with Flutter since Firebase 9 has been released anymore (or I am the only dummy which is not able to resolve this by myself).
Can someone tell me where to get the firebaseConfig object from?
If I add a new app to my project, I only get the google-services.json, which does NOT include the firebaseConfig object I need to pass.
I understand your confusion now, let me explain. When the guy in the video talks about Firebase v9 he is talking about the SDK version which in the case of Javascript (which I suppose is his main topic in his channel) is currently 9.17.1 an the version 9 has been around since 2021 so it is not new. The different SDKs have their own versions for each platform so thinking it will be the same in every SDK is a mistake by itself. You can check the SDKS here. So there is no Firebase v9, there is a Firebase SDK for javascript version 9. They managed in that way in javascript and in flutter it is not the same. Being that the last update in the flutter SDK was literally yesterday I'm pretty sure they have their reasons to not implement the same functions in flutter since 2021.
Now, one of the thinks the guy talks in the video is deconstructing, which is something common in javascript. The way you do this in flutter is by using show.
So you would be doing this for example:
import 'package:cloud_firestore/cloud_firestore.dart' show FirebaseFirestore, QuerySnapshot; //Add everything you would be using
This way only the specific parts of the library will be imported and the amount of code the Dart VM has to load will be reduced.
As of the access to documents, it is still the same but you can easily create a helper class that contents your references to your collections and then just use that class to reduce the boilerplate code created by the firebase SDK.
You have to install the Firebase CLI and run firebase init.
You need to use the package firebase_core that will give you access to the class Firebase so you can use it to initialize your app Firebase.initializeApp() you can pass the default options for the current platform using Firebase.initilizeApp(options: DefaultFirebaseOptions.currentPlatform) usually your IDE will automatically import the corresponding package but in case it does not you would have to import 'firebase/firebase_options.dart';
An useful link to the documentation: Add Firebase to your Flutter App

The getter 'filePath' is not defined for the class Asset after upgrading flutter in multi_image_picker

In my code, I am using multi_image_picker plugin for picking images from the gallery. After upgrading flutter version in my code
String fileName = await ChoosenAssets[i].filePath;//this the part gives an error
String fileName2 = fileName.split("/").last;
var asdsad['file']=await MultipartFile.fromFile(fileName,filename:fileName2,);
FormData formData = new FormData.fromMap(asdsad);
. Before this worked fine. And I downgraded flutter version the error disappeared.
So How can I get filePath with upgraded flutter version?
You can't. In the repo of the multi_image_picker package you can find this issue. In that issue the developers of the package mentioned that the filePath getter was only a experiment, but in the newest versions they removed it because it didnt work on all the operative systems nor devices. Also they mention you shouldn't need to get the filePath because:
You can do all the things you need only with the Asset.
The filePath in iOS is nowadays temporary, so even if you get it, in a few moments it will be useless.
This is a short summary, but if you need more details please go to the link I provided above.

Flutter: Display Change Log / Release Notes / "What's new" after upgrade to new app version

I'm currently searching for a while how I can implement the following feature with Flutter for Android and IOS apps:
When the application is opened the first time after a version update I'd like to show a dialog with the information what's new in the new version / what has been fixed etc. - some kind of release notes.
I know various ways to show this dialog on application start; but how can I ensure that this is done only one time after the app version changed?
I was thinking about storing the various version messages as texts on the remote backend and give them an unique ID; via shared preferences or other persistance the last shown message ID could be stored and compared to the last available one.
But I see this feature in so many apps that I suppose there's a "standard way" to do this or maybe a package which supports this.
Kind regards
Michael
I don't know if there is a standard way of doing it, but here is a simple way to do it.
Include "package_info" plugin in your project.
import 'package:package_info/package_info.dart';
PackageInfo.fromPlatform().then((PackageInfo packageInfo) {
String runningVersion = packageInfo.version;
//compare runningVersion to the one saved in sharedPrefs
//if they don't match show the message
//then save runningVersion to sharedPrefs
});
by package_info package, you can figure out the current version of the application.
if the user updates the application by release centers(like google play), information stored in sharedPreference, remains. so you can save the application's version in sharedPreference and every time the app opens check the current version with info saved in sharedPreference if is the same no need for showing release note but if the current version is higher than the stored version, show release note and update sharePreference with the new version.
PackageInfo packageInfo = await PackageInfo.fromPlatform();
String currentVersion=packageInfo.version.toString();
SharedPreferences pref= await SharedPreferences.getInstance();
String latestAppVersion= pref.getString("latestAppVersion");
if(currentVersion.toInt()>latestAppVersion.toInt()){
//show release note
//update sharedPreferences with currentVersion
}

I want to give force update feature in my app for android users

I am using ionic 3 for these and i need to give a force update feature for android users.
can i able to do it with-->
like first compare current play store version and user version and then set
a page for those users who don't have the updated version and force user's
for update the app, can i use file transfer plugin for update the app.
what approch is right?
You can use following plugins to verify that updates is available in playstore.
cordova-plugin-app-update
You should first host an XML file on your server with the following data in it:
<update>
<version>302048</version>
<name>APK Name</name>
<url>https://your-remote-api.com/YourApp.apk</url>
</update>
And then check with
constructor(private appUpdate: AppUpdate) {
const updateUrl = 'https://your-remote-api.com/update.xml';
this.appUpdate.checkAppUpdate(updateUrl).then(() => { console.log('Update
available') });
}
More details available here
Did you try this with release build package ?

Will first version local database remain in the new version of iphone application

I am bit concern about the local database I have used in my application.
I want to maintain the data enter by user in the first version of application in second version also.
So i did one exercise in which I installed app with version 1.0 and enter few entry in my database from app. Then I installed app again with the version 2.0 and the data enter in the first version app are there in the second version also. Does that mean i don't have to do anything in order to keep users first version data in second version app.
Do let me know if any one has any idea.
Thanks in advance.
Yes, the user data (including databases) will stay around after application upgrades.
When you uninstall an application, its data will also be removed.
Does that mean i don't have to do anything in order to keep users first version data in second version app.
If you have changed the database schema for the new version, you will need to provide ways to continue to be able to read the old data or convert it to the new format. Otherwise, yes, it should just work.