requestRequiredUpdate method

Future<RequiredUpdateResult> requestRequiredUpdate()

Starts the strongest available update flow from update-required UI.

Unlike a background check, this may launch an immediate update while the user is on a game route: the game is already blocked as incompatible.

Implementation

Future<RequiredUpdateResult> requestRequiredUpdate() async {
  final gateway = ref.read(appUpdateGatewayProvider);
  try {
    return await switch (gateway.platform) {
      ClientUpdatePlatform.androidPlay => _requestNativeUpdate(gateway),
      ClientUpdatePlatform.web => _reloadWeb(gateway),
      ClientUpdatePlatform.unsupported => Future.value(
        RequiredUpdateResult.unavailable,
      ),
    };
  } catch (e, stack) {
    developer.log(
      'Required update request failed',
      name: 'app.update',
      error: e,
      stackTrace: stack,
    );
    return RequiredUpdateResult.failed;
  }
}