larryaasen / upgrader

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

App Store version Returning null on Android, even after the store's listing url has been obtained. #468

Closed fiki2002 closed 1 month ago

fiki2002 commented 1 month ago

Logs for Android

I/flutter (26872): upgrader: instantiated I/flutter (26872): upgrader: initialize called I/flutter (26872): upgrader: build UpgradeAlert I/flutter (26872): upgrader: initializing I/flutter (26872): upgrader: operatingSystem: android, version: AP31.240517.022 I/flutter (26872): upgrader: packageInfo packageName: com.theoditor.mobile I/flutter (26872): upgrader: packageInfo appName: Oditor I/flutter (26872): upgrader: packageInfo version: 0.6.8 I/flutter (26872): upgrader: current locale: en_US I/flutter (26872): upgrader: countryCode: NG I/flutter (26872): upgrader: languageCode: en I/flutter (26872): upgrader: lookupById url: https://play.google.com/store/apps/details?id=com.theoditor.mobile&gl=NG&hl=en&_cb=1729245156233008 I/flutter (26872): upgrader: PlayStoreResults.redesignedVersion exception: FormatException: Not a properly formatted version string I/flutter (26872): upgrader: UpgraderPlayStore: version info: appStoreListingURL: https://play.google.com/store/apps/details?id=com.theoditor.mobile&gl=NG&hl=en&_cb=1729245157239486, appStoreVersion: null, installedVersion: 0.6.8, isCriticalUpdate: null, minAppVersion: null, releaseNotes: Can view history of restocked goods I/flutter (26872): upgrader: need to evaluate version I/flutter (26872): upgrader: blocked: false I/flutter (26872): upgrader: debugDisplayAlways: true I/flutter (26872): upgrader: debugDisplayOnce: false I/flutter (26872): upgrader: hasAlerted: false I/flutter (26872): upgrader: shouldDisplayUpgrade: true I/flutter (26872): upgrader: shouldDisplayReleaseNotes: true I/flutter (26872): upgrader: current locale: en_US I/flutter (26872): upgrader: languageCode: en I/flutter (26872): upgrader: showTheDialog title: Update App? I/flutter (26872): upgrader: showTheDialog message: A new version of Oditor is available! Version is now available-you have 0.6.8. I/flutter (26872): upgrader: showTheDialog releaseNotes: Can view history of restocked goods I/flutter (26872): upgrader: onCanPop called

It isn't detecting the app store version as shown on the image

Screenshot 2024-10-18 at 10 54 42

On iOS it sees the current store version and also sees the local version, which from the screenshot are equal and shouldn't pop up the upgrader dialog.

Screenshot 2024-10-18 at 10 42 05

Logs for iOS

flutter: upgrader: instantiated flutter: upgrader: initialize called flutter: upgrader: build UpgradeAlert flutter: upgrader: initializing flutter: upgrader: operatingSystem: ios, version: Version 17.5 (Build 21F79) flutter: upgrader: packageInfo packageName: com.theoditor.mobile flutter: upgrader: packageInfo appName: Oditor flutter: upgrader: packageInfo version: 0.6.8 flutter: upgrader: current locale: en_AE flutter: upgrader: countryCode: NG flutter: upgrader: languageCode: en flutter: upgrader: download: https://itunes.apple.com/lookup?bundleId=com.theoditor.mobile&country=NG&lang=en&_cb=1729244655218687 flutter: upgrader: UpgraderAppStore: version info: appStoreListingURL: https://apps.apple.com/ng/app/oditor/id6664065457?uo=4, appStoreVersion: 0.6.8, installedVersion: 0.6.8, isCriticalUpdate: null, minAppVersion: null, releaseNotes: null 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: false flutter: upgrader: current locale: en_US flutter: upgrader: languageCode: en flutter: upgrader: showTheDialog title: Update App? flutter: upgrader: showTheDialog message: A new version of Oditor is available! Version 0.6.8 is now available-you have 0.6.8. flutter: upgrader: showTheDialog releaseNotes: null flutter: upgrader: onCanPop called

pusbsec.lock dependency

upgrader: dependency: "direct main" description: name: upgrader sha256: "9b907a8c956dbf3f2d0430d16134e27543cba98eab31f19a2240ab1c4d920506" url: "https://pub.dev" source: hosted version: "11.3.0"

## Code snippet
class _MyAppState extends ConsumerState<OditorApp> {
  final upgrader = Upgrader(
    countryCode: 'NG',
    debugLogging: true,
    debugDisplayAlways: true,
  );

  @override
  Widget build(BuildContext context) {
    FlutterNativeSplash.remove();

    return ScreenUtilInit(
      designSize: const Size(430, 932),
      minTextAdapt: true,
      splitScreenMode: true,
      builder: (context, _) {
        return MaterialApp.router(
          routerConfig: ref.watch(routerProvider),
          title: widget.appName,
          debugShowCheckedModeBanner:
              widget.environment == AppEnvironment.development ||
                      widget.environment == AppEnvironment.testing
                  ? true
                  : false,
          theme: ThemeData(
            scaffoldBackgroundColor: AppColor.white,
            colorScheme: ColorScheme.fromSeed(
              seedColor: AppColor.primary,
            ),
            useMaterial3: true,
            fontFamily: 'Outfit',
          ),
          builder: (context, child) {
            return UpgradeAlert(
              showIgnore: false,
              showLater: false,
              upgrader: upgrader,
              navigatorKey:
                  ref.watch(routerProvider).routerDelegate.navigatorKey,
              child: child!,
            );
          },
        );
      },
    );
  }
}
larryaasen commented 1 month ago

I see that issue you have pointed out. It can be reproduced using the command line app included in this package.

% dart playstore_lookup.dart id=com.theoditor.mobile country=US

Results:

upgrader: lookupById url: https://play.google.com/store/apps/details?id=com.theoditor.mobile&gl=US&hl=en&_cb=1729252635184874
upgrader: PlayStoreResults.redesignedVersion exception: FormatException: Not a properly formatted version string
playstore_lookup description: Oditor is a modern business management application built specifically for small businesses across Africa.
playstore_lookup minAppVersion: null
playstore_lookup releaseNotes: Can view history of restocked goods
playstore_lookup version: null
playstore_lookup all results:
#document

For some reason the version is not inside the top section on the Play Store page, which is where the version is detected:

Screenshot 2024-10-18 at 8 02 08 AM
larryaasen commented 1 month ago

@humanolaranja @Williano Do either of you have thoughts on this?

humanolaranja commented 1 month ago

@humanolaranja @Williano Do either of you have thoughts on this?

Yes. The upgrader crawler for android just works for production apps. I see that this app is under open testing track (early access). That's why is not working propertly. When it wents to production track, it will works well

humanolaranja commented 1 month ago

There's no way to get the version from open testing apps. In this image, you can see the version available for your device, and this only is possible because you are logged in.

image

If you access you app in an anonymous tab, you will see that is not possible to get the version

image
larryaasen commented 1 month ago

@humanolaranja That makes sense. Thanks for looking at this.

humanolaranja commented 1 month ago

What do you think about update the docs and close this issue?

fiki2002 commented 1 month ago

Okay, @larryaasen @humanolaranja, okay so this only sorts the Android issue, on iOS, I get the upgrader dialog while the versions are the same as shown in the simulator image above

And also thank you for your swift responses🧎🏽‍♀️❤️

humanolaranja commented 1 month ago

Okay, @larryaasen @humanolaranja, okay so this only sorts the Android issue, on iOS, I get the upgrader dialog while the versions are the same as shown in the simulator image above

And also thank you for your swift responses🧎🏽‍♀️❤️

Apple provides an api to get app info, Google don't. Your android app are under early access, when publishing to production, upgrader will works well for both systems

larryaasen commented 1 month ago

For iOS you are using this parameter set to true: debugDisplayAlways: always force the upgrade to be available, defaults to false

fiki2002 commented 1 month ago

Yeah, i get that

But the issue i am having, is that it still pops the dialog up even when the iOS version are the same

larryaasen commented 1 month ago

Does it still display when debugDisplayAlways is not true? If so, please send a log with that.

humanolaranja commented 1 month ago

Yeah, i get that

But the issue i am having, is that it still pops the dialog up even when the iOS version are the same

Yeah, in the code you provided, debugDisplayAlways are set to true. Are this the issue?

fiki2002 commented 1 month ago

Ohh, i fully understand now, thank you!

fiki2002 commented 1 month ago

I'd proceed to close the issue