larryaasen / upgrader

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

When the app shows UpgradeAlert, kill the app without clicking any button, and will not show UpgradeAlert when the app is opened again #444

Open dylan-huang-1024 opened 2 months ago

dylan-huang-1024 commented 2 months ago

hi, When using the upgrader: ^10.3.0, I encountered such a scene. I don't know if it is a bug or a normal behavior. Please give your opinion, thanks.

[reproduce step]:

  1. open the app and show UpgradeAlert correctly
  2. without clicking any button, just kill the app
  3. reopen the app, cannot show UpgradeAlert again
  4. but can show UpgradeAlert after durationUntilAlertAgain.

remark: just like the behavior that I clicked the [Later] button [expected result]: step3: should show UpgradeAlert again

other infomations:

$ flutter doctor Doctor summary (to see all details, run flutter doctor -v): [√] Flutter (Channel stable, 3.22.2, on Microsoft Windows [版本 10.0.22631.4112], locale zh-CN) [√] Windows Version (Installed version of Windows is version 10 or higher) [√] Android toolchain - develop for Android devices (Android SDK version 34.0.0) [√] Chrome - develop for the web [X] Visual Studio - develop Windows apps X Visual Studio not installed; this is necessary to develop Windows apps. Download at https://visualstudio.microsoft.com/downloads/. Please install the "Desktop development with C++" workload, including all of its default components [√] Android Studio (version 2023.3) [√] IntelliJ IDEA Community Edition (version 2024.1) [√] VS Code (version unknown) X Unable to determine VS Code version. [√] Connected device (4 available) [!] Network resources X A network error occurred while checking "https://maven.google.com/": 信号灯超时时间已到

! Doctor found issues in 2 categories.

logs: I/flutter (10284): upgrader: instantiated I/flutter (10284): upgrader: initialize called I/flutter (10284): upgrader: initializing I/flutter (10284): upgrader: operatingSystem: android, version: sdk_gphone64_x86_64-userdebug 14 UE1A.230829.036.A2 11596452 dev-keys I/flutter (10284): upgrader: packageInfo packageName: xxx I/flutter (10284): upgrader: packageInfo appName: XXX I/flutter (10284): upgrader: packageInfo version: 1.2.10 I/flutter (10284): upgrader: current locale: en_US I/flutter (10284): upgrader: countryCode: US I/flutter (10284): upgrader: languageCode: en I/flutter (10284): upgrader: UpgraderAppStore: version info: appStoreListingURL: xxx, appStoreVersion: 1.2.56, installedVersion: 1.2.10, isCriticalUpdate: false, minAppVersion: 1.2.9, releaseNotes: null I/flutter (10284): upgrader: initialize called I/flutter (10284): upgrader: build UpgradeAlert I/flutter (10284): upgrader: need to evaluate version I/flutter (10284): upgrader: blocked: false I/flutter (10284): upgrader: debugDisplayAlways: false I/flutter (10284): upgrader: debugDisplayOnce: false I/flutter (10284): upgrader: hasAlerted: false I/flutter (10284): upgrader: installedVersion: 1.2.10 I/flutter (10284): upgrader: minAppVersion: null I/flutter (10284): upgrader: isUpdateAvailable: true I/flutter (10284): upgrader: isTooSoon: true I/flutter (10284): upgrader: shouldDisplayUpgrade: false I/flutter (10284): upgrader: shouldDisplayReleaseNotes: false I/flutter (10284): upgrader: initialize called I/flutter (10284): upgrader: build UpgradeAlert I/flutter (10284): upgrader: need to evaluate version I/flutter (10284): upgrader: blocked: false I/flutter (10284): upgrader: debugDisplayAlways: false I/flutter (10284): upgrader: debugDisplayOnce: false I/flutter (10284): upgrader: hasAlerted: false I/flutter (10284): upgrader: installedVersion: 1.2.10 I/flutter (10284): upgrader: minAppVersion: null I/flutter (10284): upgrader: isUpdateAvailable: true I/flutter (10284): upgrader: isTooSoon: true I/flutter (10284): upgrader: shouldDisplayUpgrade: false I/flutter (10284): upgrader: shouldDisplayReleaseNotes: false I/flutter (10284): upgrader: build UpgradeAlert I/flutter (10284): upgrader: need to evaluate version I/flutter (10284): upgrader: blocked: false I/flutter (10284): upgrader: debugDisplayAlways: false I/flutter (10284): upgrader: debugDisplayOnce: false I/flutter (10284): upgrader: hasAlerted: false I/flutter (10284): upgrader: installedVersion: 1.2.10 I/flutter (10284): upgrader: minAppVersion: null I/flutter (10284): upgrader: isUpdateAvailable: true I/flutter (10284): upgrader: isTooSoon: true I/flutter (10284): upgrader: shouldDisplayUpgrade: false I/flutter (10284): upgrader: shouldDisplayReleaseNotes: false I/flutter (10284): upgrader: initialize called I/flutter (10284): upgrader: build UpgradeAlert I/flutter (10284): upgrader: need to evaluate version I/flutter (10284): upgrader: blocked: false I/flutter (10284): upgrader: debugDisplayAlways: false I/flutter (10284): upgrader: debugDisplayOnce: false I/flutter (10284): upgrader: hasAlerted: false I/flutter (10284): upgrader: installedVersion: 1.2.10 I/flutter (10284): upgrader: minAppVersion: null I/flutter (10284): upgrader: isUpdateAvailable: true I/flutter (10284): upgrader: isTooSoon: true I/flutter (10284): upgrader: shouldDisplayUpgrade: false I/flutter (10284): upgrader: shouldDisplayReleaseNotes: false I/flutter (10284): upgrader: build UpgradeAlert I/flutter (10284): upgrader: need to evaluate version I/flutter (10284): upgrader: blocked: false I/flutter (10284): upgrader: debugDisplayAlways: false I/flutter (10284): upgrader: debugDisplayOnce: false I/flutter (10284): upgrader: hasAlerted: false I/flutter (10284): upgrader: installedVersion: 1.2.10 I/flutter (10284): upgrader: minAppVersion: null I/flutter (10284): upgrader: isUpdateAvailable: true I/flutter (10284): upgrader: isTooSoon: true I/flutter (10284): upgrader: shouldDisplayUpgrade: false I/flutter (10284): upgrader: shouldDisplayReleaseNotes: false I/flutter (10284): upgrader: initialize called I/flutter (10284): upgrader: build UpgradeAlert I/flutter (10284): upgrader: need to evaluate version I/flutter (10284): upgrader: blocked: false I/flutter (10284): upgrader: debugDisplayAlways: false I/flutter (10284): upgrader: debugDisplayOnce: false I/flutter (10284): upgrader: hasAlerted: false I/flutter (10284): upgrader: installedVersion: 1.2.10 I/flutter (10284): upgrader: minAppVersion: null I/flutter (10284): upgrader: isUpdateAvailable: true I/flutter (10284): upgrader: isTooSoon: true I/flutter (10284): upgrader: shouldDisplayUpgrade: false I/flutter (10284): upgrader: shouldDisplayReleaseNotes: false I/flutter (10284): upgrader: build UpgradeAlert I/flutter (10284): upgrader: need to evaluate version I/flutter (10284): upgrader: blocked: false I/flutter (10284): upgrader: debugDisplayAlways: false I/flutter (10284): upgrader: debugDisplayOnce: false I/flutter (10284): upgrader: hasAlerted: false I/flutter (10284): upgrader: installedVersion: 1.2.10 I/flutter (10284): upgrader: minAppVersion: null I/flutter (10284): upgrader: isUpdateAvailable: true I/flutter (10284): upgrader: isTooSoon: true I/flutter (10284): upgrader: shouldDisplayUpgrade: false I/flutter (10284): upgrader: shouldDisplayReleaseNotes: false

Kaizodo commented 2 months ago

426 Possible duplicate and a solution as well hope someone will create a pr for this.

phamgiaminh0112 commented 2 months ago

I have corrected this error and created a pull request. In that you just need to remove the isTooSoon() condition in file src/upgrader.dart line number 306. And don't forget to set showIgnore = false and showLater = false if you don't want users to skip the update.

larryaasen commented 2 months ago

There is a parameter on Upgrader called durationUntilAlertAgain which is set to const Duration(days: 3) (3 days) by default. That is what causes isTooSoon to be true. This is designed to prevent the alert from annoying a user with prompts over and over repeatedly. If you do not like that behavior, change durationUntilAlertAgain to a shorter duration.