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

Is there any callback to check update available programmatically ? #388

Open
rajrajputgs opened this issue Mar 1, 2024 · 6 comments
Open
Labels
How To? This is a how to question

Comments

@rajrajputgs
Copy link

UpgradeAlert(
showIgnore: false,
upgrader: Upgrader(
durationUntilAlertAgain: const Duration(milliseconds: 500),
),
shouldPopScope: () => false,
child:Text('Test Data'),
)

Currently, we are using this code to check force update from play store but this code only work on ui side not for programming side, so is there any way to check app update or any callback available ?

@larryaasen
Copy link
Owner

@rajrajputgs Look at the code for UpgradeAlert and copy the relevant parts that you need.

@larryaasen larryaasen added the How To? This is a how to question label Mar 2, 2024
@rajrajputgs
Copy link
Author

rajrajputgs commented Mar 4, 2024 via email

@larryaasen
Copy link
Owner

@rajrajputgs
You can use something like this:

final upgrader = Upgrader();
upgrader.initialize().then((value) {
  if (upgrader.isUpdateAvailable()) {
    print('$upgrader.currentAppStoreVersion}');
  }
});

@GokulP48
Copy link

@rajrajputgs You can use something like this:

final upgrader = Upgrader();
upgrader.initialize().then((value) {
  if (upgrader.isUpdateAvailable()) {
    print('$upgrader.currentAppStoreVersion}');
  }
});

This doesn't work though

@larryaasen
Copy link
Owner

@GokulP48 What part doesn't work? Do you have any logs you can share?

@GokulP48
Copy link

class MyApp extends ConsumerStatefulWidget {
const MyApp({super.key});

@OverRide
ConsumerState createState() => _MyAppState();
}

class _MyAppState extends ConsumerState {
@OverRide
void initState() {
super.initState();
ref.read(authProvider.notifier).isNewUser();
ref.read(authProvider.notifier).init();
}

@OverRide
Widget build(BuildContext context) {
final AuthState authState = ref.watch(authProvider);
switch (authState) {
case AuthState.unAuth:
final bool isNewUser = ref.read(authProvider.notifier).newUser;
return isNewUser ? const OnboardScreen() : const LoginScreen();
case AuthState.auth:
// PushNotification().initialize();

    final upgrader = Upgrader();
    upgrader.initialize().then((value) {
      if (upgrader.isUpdateAvailable()) {
        return const AppUpdateAvailable();
      }
    });
    final AddressModel address =
        ref.read(userProvider.notifier).userAddress;
    return address.addressId == null
        ? const FindLocationScreen()
        : const MainScreen();
  default:
    return const DefaultScreen();
}

}
}

this is my code , I hope you understand what i trying to do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
How To? This is a how to question
Projects
None yet
Development

No branches or pull requests

3 participants