larryaasen / upgrader

A Flutter package for prompting users to upgrade when there is a newer version of the app in the store.
MIT License
523 stars 258 forks source link

can't use durationUntilAlertAgain #390

Open alexlozdev opened 4 months ago

alexlozdev commented 4 months ago

Flutter sdk 3.19.0 upgrader: ^9.0.0 OS: android

Even, it doesn't display the upgradeAlert.

UpgradeAlert(
      showIgnore: false,
      showReleaseNotes: false,
      upgrader: Upgrader(
        debugDisplayAlways: true,
        durationUntilAlertAgain: const Duration(seconds: 30),
      ),
      child: Container()
);

This works without specifying upgrader.

UpgradeAlert(
      showIgnore: false,
      showReleaseNotes: false,
      child: Container()
);

I tested every code after uninstalling app fully.

larryaasen commented 3 months ago

@alexlozdev I updated the example/main.dart file with these options and it works for me. Is there more information you can provide about this? Do you have the upgrader log?

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Upgrader Example',
      home: UpgradeAlert(
        showIgnore: false,
        showReleaseNotes: false,
        upgrader: Upgrader(
          debugLogging: true,
          debugDisplayAlways: true,
          durationUntilAlertAgain: const Duration(seconds: 30),
        ),
        child: Scaffold(
          appBar: AppBar(title: const Text('Upgrader Example')),
          body: const Center(child: Text('Checking...')),
        ),
      ),
    );
  }
alexlozdev commented 3 months ago

@alexlozdev I updated the example/main.dart file with these options and it works for me. Is there more information you can provide about this? Do you have the upgrader log?

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Upgrader Example',
      home: UpgradeAlert(
        showIgnore: false,
        showReleaseNotes: false,
        upgrader: Upgrader(
          debugLogging: true,
          debugDisplayAlways: true,
          durationUntilAlertAgain: const Duration(seconds: 30),
        ),
        child: Scaffold(
          appBar: AppBar(title: const Text('Upgrader Example')),
          body: const Center(child: Text('Checking...')),
        ),
      ),
    );
  }

Can you see upgrade alert every 30s if you clicked "Later"?

larryaasen commented 3 months ago

@alexlozdev Yes, I do see the alert again after the duration expires. Note that the alert doesn't just pop up after 30 seconds. The upgrader code only runs upon app startup and after returning from the background. So, after 30 seconds, background the app and return to the app, and you will see the alert. You do not want upgrader to be running all the time and you would not want the alert to pop up in the middle of a critical user experience.

alexlozdev commented 3 months ago

I found the issue reason This code doesn't work.

UpgradeAlert(
        showIgnore: false,
        showReleaseNotes: false,
        upgrader: Upgrader(
          debugLogging: true,
          debugDisplayAlways: true,
          durationUntilAlertAgain: const Duration(seconds: 30),
        ),
        child: Scaffold(
          appBar: AppBar(title: const Text('Upgrader Example')),
          body: const Center(child: Text('Checking...')),
        ),
      ),

This code works well

final _upgrader = Upgrader(
          debugLogging: true,
          debugDisplayAlways: true,
          durationUntilAlertAgain: const Duration(seconds: 30),
        );

Widget build() {
   UpgradeAlert(
        showIgnore: false,
        showReleaseNotes: false,
        upgrader: _upgrader,
        child: Scaffold(
          appBar: AppBar(title: const Text('Upgrader Example')),
          body: const Center(child: Text('Checking...')),
        ),
      ),
}

I think that Upgrader() has async code, So if it creates Upgrader() previously, it works well. If not, it doesn't work properly.