Manolis Dame
Manolis Dame

Reputation: 53

Remote Config values always returning null for Flutter/Firebase application

I'm trying to set up a force update message in my application. In Firebase Remote Config i am defining:

All of these are strings.

I have a VersionChecker class in which i initialize remote config like so:

  static Future<VersionChecker> initialize() async {
    try {
      final remoteConfig = FirebaseRemoteConfig.instance;

      // Set configuration
      await remoteConfig.setConfigSettings(
        RemoteConfigSettings(
          fetchTimeout: const Duration(minutes: 1),
          minimumFetchInterval: Duration.zero,
        ),
      );

      // Fetch the values from Firebase Remote Config
      bool fetchSuccess = await remoteConfig.fetchAndActivate();

      if (!fetchSuccess) {
        print('Failed to fetch and activate remote config');
      }

      // Add validation for empty values
      final values = remoteConfig.getAll();
      if (values.isEmpty) {
        print('Warning: Remote config returned empty values');
      }

      print(
          'Latest Android: ${remoteConfig.getString(LATEST_ANDROID_VERSION_KEY)}');
      print('Min Android: ${remoteConfig.getString(MIN_ANDROID_VERSION_KEY)}');
      print('Latest iOS: ${remoteConfig.getString(LATEST_IOS_VERSION_KEY)}');
      print('Min iOS: ${remoteConfig.getString(MIN_IOS_VERSION_KEY)}');
      return VersionChecker._(remoteConfig: remoteConfig);
    } catch (e, stackTrace) {
      print('Error initializing VersionChecker: $e');
      print('Stack trace: $stackTrace');
      rethrow;
    }
  }


I have purposefully avoided setting defaults for these values for now as all it does is fall back on those every time.

The issue Im getting is that no matter what i try the remote config always returns no values for those strings.

W/Parcel  ( 4201): Expecting binder but got null!
W/System  ( 4201): Ignoring header If-None-Match because its value was null.
D/TrafficStats( 4201): tagSocket(144) with statsTag=0xffffffff, statsUid=-1
D/FRCPlugin( 4201): Sending fetchTimeout: 60
I/flutter ( 4201): Warning: Remote config returned empty values
I/flutter ( 4201): Latest Android:
I/flutter ( 4201): Min Android:
I/flutter ( 4201): Latest iOS:
I/flutter ( 4201): Min iOS:
D/EGL_emulation( 4201): app_time_stats: avg=27.50ms min=3.98ms max=145.80ms count=35
I/flutter ( 4201): Remote config values: {}
I/flutter ( 4201): Error comparing versions: FormatException: Invalid number (at character 1)
I/flutter ( 4201):
I/flutter ( 4201): ^
I/flutter ( 4201): Error comparing versions: FormatException: Invalid number (at character 1)
I/flutter ( 4201):
I/flutter ( 4201): ^
I/flutter ( 4201): Is lower than minimum: false
I/flutter ( 4201): Is lower than latest: false
I/flutter ( 4201): ====================================
I/flutter ( 4201): No update required
I/flutter ( 4201): NotificationsService: Initialized
D/ProfileInstaller( 4201): Installing profile for com.foundermatcha.foundermatcha
D/EGL_emulation( 4201): app_time_stats: avg=428.58ms min=36.59ms max=2092.93ms count=6
count=4

I have tried adding a forceRefresh method

I've also attached an image of my RC in the Firebase Console, I believe I've set this up right but maybe this is where the issue could be?

Picture of Firebase Console

Any help appreciated thanks

Upvotes: 0

Views: 76

Answers (0)

Related Questions