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

Dialog not showing anything despite the logs saying it should. #434

Open davidgtu opened 3 months ago

davidgtu commented 3 months ago

Thank you for making this package.

I'm trying to implement this feature into my app but I can't seem to see it working locally despite my logs saying otherwise.

In my attempt to test this, In my pubspec.yaml I tried to fake the version. My app is live with the version 3.22.2, and in pubspec.yaml I switched it so something lower, 3.22.0, but it doesn't work.

Here are my upgrader logs:

flutter: upgrader: instantiated
flutter: upgrader: initialize called
flutter: upgrader: build UpgradeAlert
flutter: upgrader: initializing
flutter: upgrader: operatingSystem: ios, version: Version 16.4 (Build 20E247)
flutter: upgrader: packageInfo packageName: com.xxx.xxx1
flutter: upgrader: packageInfo appName: xxx
flutter: upgrader: packageInfo version: 3.22.0
flutter: upgrader: current locale: en
flutter: upgrader: countryCode: US
flutter: upgrader: languageCode: en
flutter: upgrader: download: https://itunes.apple.com/lookup?bundleId=com.xxx.xxx1&country=US&_cb=1723226892210360
flutter: upgrader: response statusCode: 200
flutter: upgrader: UpgraderAppStore: version info: appStoreListingURL: https://apps.apple.com/us/app/xxx/xxx?uo=4, appStoreVersion: 3.22.2, installedVersion: 3.22.0, isCriticalUpdate: null, minAppVersion: null, releaseNotes: - Bug fixes
flutter: upgrader: need to evaluate version
flutter: upgrader: blocked: false
flutter: upgrader: debugDisplayAlways: false
flutter: upgrader: debugDisplayOnce: false
flutter: upgrader: hasAlerted: false
flutter: upgrader: installedVersion: 3.22.0
flutter: upgrader: minAppVersion: null
flutter: upgrader: isUpdateAvailable: true
flutter: upgrader: shouldDisplayUpgrade: true
flutter: upgrader: shouldDisplayReleaseNotes: true
flutter: upgrader: current locale: en
flutter: upgrader: languageCode: en
flutter: upgrader: showTheDialog title: Update App?
flutter: upgrader: showTheDialog message: A new version of Recora is available! Version 3.22.2 is now available-you have 3.22.0.
flutter: upgrader: showTheDialog releaseNotes: - Bug fixes

My assumption is that shouldDisplayUpgrade should mean it should display something, right? Is there anything blocking the dialog from displaying?

I've added UpgradeAlert to the top-level of my app as well:

 runApp(
      riverpod.ProviderScope(
        child: UpgradeAlert(
          upgrader: Upgrader(
            debugLogging: true,
          ),
          child: const App(),
        ),
      ),
    );

am I missing something? Is there something in the background that I'm not aware of and wouldn't work just by faking the version?

Thank you all.

larryaasen commented 3 months ago

Looking at the log you provided I see that the dialog was to be displayed: flutter: upgrader: showTheDialog title: Update App? I think UpgradeAlert is too high in your widget tree because it need to be below MaterialApp. This may help from the example:

    return MaterialApp(
      title: 'Upgrader Example',
      home: UpgradeAlert(
        child: Scaffold(
          appBar: AppBar(title: const Text('Upgrader Example')),
          body: const Center(child: Text('Checking...')),
        ),
      ),
    );
ravinder-gs commented 3 months ago

I am facing same issue,

flutter: upgrader: response statusCode: 200
flutter: upgrader: UpgraderAppStore: version info: appStoreListingURL: https://apps.apple.com/in/app/colel-chabad-pushka/id1491701168?uo=4, appStoreVersion: 2.1.0, installedVersion: 1.0.0, isCriticalUpdate: null, minAppVersion: null, releaseNotes: - Share button
- Updated Settings Page
flutter: upgrader: need to evaluate version
flutter: upgrader: blocked: false
flutter: upgrader: debugDisplayAlways: true
flutter: upgrader: debugDisplayOnce: false
flutter: upgrader: hasAlerted: false
flutter: upgrader: shouldDisplayUpgrade: true
flutter: upgrader: shouldDisplayReleaseNotes: true
flutter: upgrader: current locale: en_US
flutter: upgrader: languageCode: en
flutter: upgrader: showTheDialog title: Update App?
flutter: upgrader: showTheDialog message: A new version of Pushka is available! Version 2.1.0 is now available-you have 1.0.0.
flutter: upgrader: showTheDialog releaseNotes: - Share button

My Code

MyAppProvider(
      child: MaterialApp.router(
        routerConfig: navigator.config(),
        title: F.title,
        locale: DevicePreview.locale(context),
        builder: (context, child) {
          return UpgradeAlert(
            upgrader: Upgrader(
              debugLogging: true,
              debugDisplayAlways: true,
              countryCode: 'US',
              minAppVersion: '1.0.0',
              languageCode: 'en',
              messages: UpgraderMessages(
                code: "en",
              ),
            ),
            child: child ?? const Text('child'),
          );

        },
        debugShowCheckedModeBanner: false,
        theme: appTheme,
      ),
    )
akshatjain-beam commented 1 month ago

@davidgtu , kindly check this -