Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to force users to update app from play store in Flutter using in_app_update

I want the users of my app to always have the latest version. If they don't have the latest version, it should download the latest version from play store first as shown in the image.

Forced Update

I found a package called Upgrader but this just gives a prompt. It is not linked to play store as shown in image.

Edit

As suggested by Maadhav Sharma, now I am using the in_app_update package but it says no update available.

This is my code:

....

class _TnPState extends State<TnP> {
  ThemeBloc _themeBloc;
  FirebaseMessaging _firebaseMessaging;
  NotificationBloc _notificationBloc;
  String _test;

  @override
  void initState() {
    _themeBloc = ThemeBloc();
    _firebaseMessaging = FirebaseMessaging();
    _notificationBloc = NotificationBloc();
    _firebaseMessaging.configure(
      onMessage: (notification) async => _notificationBloc.yes(),
      onResume: (notification) async => _notificationBloc.yes(),
      onLaunch: (notification) async => _notificationBloc.yes(),
    );
    checkForUpdate();
    super.initState();
  }

  Future<void> checkForUpdate() async {
    InAppUpdate.checkForUpdate().then((info) {
      String display = info.toString();
      setState((){
        _test = display;
      });
    });
  }

  @override
  Widget build(BuildContext context) {
    return StreamBuilder<AppTheme>(
      stream: _themeBloc.themeStream,
      initialData: AppTheme.Light,
      builder: (context, AsyncSnapshot<AppTheme> snapshot) {
        return MaterialApp(
          title: 'TnP',
          debugShowCheckedModeBanner: false,
          theme: appThemeData[snapshot.data],
          home: _test==null ?
                Container() : 
                InAppUpdateScreen(display: _test),//SplashScreen(),
        );
      },
    );
  }
}

InAppUpdateScreen just displays the text.
App in play store shows update is available:
App in play store


But the app which is an older version installed via playstore shows no update:
No update in app


Any idea how to solve this?

like image 700
Md Azharuddin Avatar asked Jun 01 '20 09:06

Md Azharuddin


People also ask

How do I automatically update apps on flutter?

flutter_updater. This library allows you to easily add auto-update functionality to your Android, iOS, and Windows Flutter application. Our use case was to update the app by launching the App Store on iOS or install/execute the Android APK or Windows executable; thus, this package was born.

How do I update my flutter app on Play Store?

An Android App Bundle is a file (with the . aab file extension) that you upload to Google Play to support Dynamic Delivery. So to make new changes that you made to your app's functionality - you should upload the aab file. You can find app bundle files located in build/app/outputs within your app's folder.

How do I update my apps without Play store fluttering?

How to update app version in Flutter. To update the app version in Flutter, you can simply open the pubspec. yaml file and then update the version tag. Inside the version tag, just increase the build number (for Android) or CFBundleVersion (for iOS).

How do I force the app user to update?

For forcing the app user to update if an update is available in the market, you should first check the app version on the market and compare it with the version of the app on the device. If they are different, it may be an update available.

What happens if users don’t update the app?

I have an app in Google Play Store. When an update version is available, the older version will become unusable – that is, if users do not update the app, they do not enter in the app. How can I force users to update the app when a new version becomes available?

How to notify users when the app is being updated?

The library provides you 2 different ways to notify the users about the update: Flexible, when users can continue using the app while it is being updated in the background. Immediate - blocking screen that doesn't allow a user to enter the app until they update it. There are next steps to implement it:

How to make an app updatable on Play Store?

3- when you submit a new release with a different version code number, then PlayStore will make your app updatable. so always make sure to change your versionCode first and then create a new release after that


1 Answers

There is a package for what you want:

https://pub.dev/packages/in_app_update
enter image description here

Android
This plugin integrates the official Android APIs to perform in app updated that were released in 2019: https://developer.android.com/guide/app-bundle/in-app-updates

iOS
iOS does not offer such a functionality. You might want to look into e.g. https://pub.dev/packages/upgrader. If you call the methods above on a iOS device you'll run into a not-implemented exception.

Thanks...

like image 125
Maadhav Sharma Avatar answered Sep 28 '22 04:09

Maadhav Sharma