From 8d8ac767123518cd5666f29e6eaf57017fd8c67b Mon Sep 17 00:00:00 2001 From: Avni Prajapati Date: Tue, 24 Jun 2025 11:56:18 +0530 Subject: [PATCH] Updated firebase_remote_config_service.dart - Added try-catch to handle error in Remote Config initialisation. - Added 'force_update' key and assigned JSON value to it while set up initial default values, to match Firebase's variable configuration. --- .../firebase_remote_config_service.dart | 35 +++++++++++-------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/apps/app_core/lib/core/data/services/firebase_remote_config_service.dart b/apps/app_core/lib/core/data/services/firebase_remote_config_service.dart index ca739a0..d825b53 100644 --- a/apps/app_core/lib/core/data/services/firebase_remote_config_service.dart +++ b/apps/app_core/lib/core/data/services/firebase_remote_config_service.dart @@ -1,4 +1,5 @@ import 'package:firebase_remote_config/firebase_remote_config.dart'; +import 'package:app_core/app/helpers/logger_helper.dart'; ///In your firebase console, you can set the default values for your app. ///The json will looks like this: @@ -24,25 +25,29 @@ class FirebaseRemoteConfigService { Future _setDefaults() async { await _remoteConfig.setDefaults(const { - 'android': ''' - { - "version": "1.0.0", - "allow_cancel": true - } - ''', - 'ios': ''' - { - "version": "1.0.0", - "allow_cancel": true - } - ''', + 'force_update': ''' + { + "android": { + "version": "1.0.0", + "allow_cancel": true + }, + "ios": { + "version": "1.0.0", + "allow_cancel": true + } + } + ''', }); } Future initialize() async { - await _setConfigSettings(); - await _setDefaults(); - await fetchAndActivate(); + try { + await _setConfigSettings(); + await _setDefaults(); + await fetchAndActivate(); + } catch (e) { + flog('Error initializing Firebase Remote Config: $e'); + } } Future fetchAndActivate() async {