Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not pop the dialog when 'Update' is clicked. #416

Open
hsynksahin opened this issue May 28, 2024 · 5 comments
Open

Do not pop the dialog when 'Update' is clicked. #416

hsynksahin opened this issue May 28, 2024 · 5 comments

Comments

@hsynksahin
Copy link

hsynksahin commented May 28, 2024

I'm using the package without any major problems but today something strange happen.

One of my apps that's in production did got a update release today and we forcefully updated every cleint. There for user saw only the update button, can not ignore, can not deny has to update the app. The problem is when the user clicked the update button it didnt throw the link successfully. But the dialog popped and user was abel to use the old version without any problems. And the dialog didnt shown again when application re-started.

I dont know why the lauchUrl not worked, but I've overrided the onUpdate event with my own launchUrl functions so hope this wont happen again. But why the dialog is not shown again ? Why dialog popped ? Can I request a parameter like bool popDialogOnUpdate = true that programmer can set false in situations like this ?

About dialog is not being shown again, probably because I've forgot the durationUntilAlertAgain as 24 hours. That part is my mistake, but shouldn't the upgrader detect the critical update and ignore this duration ? (I've set the duration to 1 second now. Dont know if it works)

@larryaasen
Copy link
Owner

To better assist in analyzing this issue, please include all of the upgrader log, which can be enabled by setting debugLogging to true.

@hsynksahin
Copy link
Author

hsynksahin commented May 28, 2024

I can't get that log from a release mode app so I've reverted to an older version for this, here is the builder method wraps my app :

Code details upgrader: ^10.3.0 url_launcher: ^6.2.6
class UpgraderWrapper extends StatelessWidget {
  const UpgraderWrapper({
    super.key,
    required this.child,
  });

  static bool didLog = false;

  final Widget child;

  @override
  Widget build(BuildContext context) => UpgradeAlert(
        showLater: false,
        showIgnore: false,
        showReleaseNotes: false,
        barrierDismissible: false,
        dialogStyle: Platform.isIOS ? UpgradeDialogStyle.cupertino : UpgradeDialogStyle.material,
        onUpdate: () {
          Log.info('[UpgraderAlert] Directing to update');
          return true;
        },
        onLater: () => false,
        onIgnore: () => false,
        shouldPopScope: () => false,
        upgrader: Upgrader(
          debugDisplayAlways: true,
          durationUntilAlertAgain: const Duration(seconds: 1),
          debugLogging: const bool.fromEnvironment('logUpgrader', defaultValue: false),
          countryCode: Localization.currentLocale(context).countryCode,
          languageCode: Localization.currentLocale(context).languageCode,
          willDisplayUpgrade: ({required display, installedVersion, versionInfo}) {
            if (didLog || kReleaseMode) {
              didLog = true;
              Log.info('[UpgraderAlert] Will display: $display\n'
                  'Installed version: $installedVersion\n'
                  'AppStore version: ${versionInfo?.appStoreVersion?.toString()}\n'
                  'Min version : ${versionInfo?.minAppVersion?.toString()}\n'
                  'Critical: ${versionInfo?.isCriticalUpdate?.toString()}');
            }
          },
        ),
        child: child,
      );
}

I've updated this code a little on the current version but the upgrader part is the same only the onUpdate button changed as I said. But the dialog is not showing still. For the log, I've tryed to filter them trough my own logs, Here is the log: (censored the links etc. they are fine)

Logs
I/flutter (17402): upgrader: instantiated
I/flutter (17402): upgrader: initialize called
I/flutter (17402): upgrader: build UpgradeAlert
I/flutter (17402): upgrader: initializing
I/flutter (17402): upgrader: operatingSystem: android, version: SNE-LX1 10.0.0.245(C432E9R1P1)
I/flutter (17402): upgrader: packageInfo packageName: <censor>
I/flutter (17402): upgrader: packageInfo appName: <censor>
I/flutter (17402): upgrader: packageInfo version: 0.2.5
I/flutter (17402): upgrader: current locale: en_TR
I/flutter (17402): upgrader: countryCode: TR
I/flutter (17402): upgrader: languageCode: en
I/flutter (17402): upgrader: lookupById url: <censor>
I/flutter (17402): upgrader: instantiated
I/flutter (17402): upgrader: build UpgradeAlert
I/flutter (17402): upgrader: UpgraderPlayStore.minAppVersion: 0.2.7
I/flutter (17402): upgrader: UpgraderPlayStore: version info: appStoreListingURL: <censor>,  appStoreVersion: 0.2.7, installedVersion: 0.2.5, isCriticalUpdate: null, minAppVersion: 0.2.7, releaseNotes: 0.2.7: <...>

also the willDisplayUpgradenot being called

IMPORTANT: this is the debugMode test I've done and the error (no dialog) im getting is not the same as I saw in the production apps.

@hsynksahin
Copy link
Author

Btw, this app only uses Critical updates. We have to dont let the user use the older versions.

I've confirmed from user devices that on both Android & Ios update the dialog is shown in the first or second app start (for the first time). Then the user presses to the Update Now button and dialog pops (that should NOT pop I think). And its not forwarding to AppStore/GooglePlay. The user keeps using the old version...

Afterwards after few closing&opening the app, sometimes the dialog is shown again (even tho in that version duration is set to 24 hours, which is good). And non of the dialogs are forwarding to appstore.

If user not presses to update button and closes the app&opens again. Dialog did not shown and user keeps using the old version.

Clearly something wrong here. Need some help or I will have to write version controller from my own server which wont be healthy i think.

@hsynksahin
Copy link
Author

Just realized that tha crashlytics system was telling me the app is %100 healty then after update everyone took an error that made the app %4 crash free (LOL).

Error in return: FlutterError - upgrader: initialize() not called. Must be called first.

Last 3 Stack Trace:

upgrader.dart - Line 265
Upgrader.appName + 265

upgrader.dart - Line 277
Upgrader.body + 277

upgrade_alert.dart - Line 148
UpgradeAlertState.checkVersion. + 148

@qwertie
Copy link

qwertie commented Jul 9, 2024

UpgradeCard has essentially the same issue as UpgradeAlert. If the user clicks "Update" but doesn't actually update the app, the UpgradeCard disappears even if showIgnore: false and showLater: false. This occurs because the button handler calls widget.upgrader.saveLastAlerted() before opening the app store and even before calling the user callback. I tried to work around this with

  if (isMandatory) {
    Future(() async {
      await Upgrader.clearSavedSettings();
      await _upgrader!.getSavedPrefs();
      setState(() {}); // force refresh (requires parent widget to be StatefulWidget)
    });
  }

But this doesn't work either, because getSavedPrefs ignores the saved preference if it is null. However, calling Upgrader.clearSavedSettings() is still useful for allowing the UpgradeAlert/UpgradeCard to reappear next time the app is restarted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants