@@ -9,28 +9,20 @@ import com.woozoo.menumonya.R
99import kotlinx.coroutines.Dispatchers
1010import kotlinx.coroutines.withContext
1111
12- class RemoteConfigRepository {
13- private val remoteConfig = FirebaseRemoteConfig .getInstance()
12+ object RemoteConfigRepository {
1413
15- companion object {
16- private var instance : RemoteConfigRepository ? = null
17-
18- fun initialize () {
19- if (instance == null ) {
20- instance = RemoteConfigRepository ()
21- }
22- }
23-
24- fun get (): RemoteConfigRepository {
25- return instance ? : throw java.lang. IllegalStateException ( " RemoteConfigRepository must be initialized " )
14+ /* *
15+ * Firebase Remote Config 관련 초기화 작업
16+ * - Application.kt의 onCreate()에서 호출함.
17+ * - 해당 로직이 실행되지 않은 상태에서 getString()을 호출할 경우 오류가 발생함.
18+ * - setDefaultAsnyc()가 호출되지 않았기 때문.
19+ * - TODO : 추후 스플래시 화면이 생긴다면 호출 타이밍을 변경해야 함.
20+ */
21+ fun initializeRemoteConfig () {
22+ val remoteConfig = FirebaseRemoteConfig .getInstance()
23+ val configSettings = remoteConfigSettings {
24+ minimumFetchIntervalInSeconds = REMOTE_CONFIG_FETCH_INTERVAL
2625 }
27- }
28-
29- private val configSettings = remoteConfigSettings {
30- minimumFetchIntervalInSeconds = REMOTE_CONFIG_FETCH_INTERVAL
31- }
32-
33- init {
3426 remoteConfig.setDefaultsAsync(R .xml.remote_config_defaults)
3527 remoteConfig.setConfigSettingsAsync(configSettings)
3628 remoteConfig.fetchAndActivate().addOnCompleteListener { task ->
@@ -42,23 +34,29 @@ class RemoteConfigRepository {
4234 }
4335 }
4436
45- suspend fun getRestaurantsCollectionName () = withContext(Dispatchers .IO ) {
37+ suspend fun getRestaurantsCollectionNameConfig () = withContext(Dispatchers .IO ) {
38+ val remoteConfig = FirebaseRemoteConfig .getInstance()
39+
4640 if (BuildConfig .DEBUG ) {
4741 remoteConfig.getString(" RESTAURANT_COLLECTION_DEV" )
4842 } else {
4943 remoteConfig.getString(" RESTAURANT_COLLECTION_PROD" )
5044 }
5145 }
5246
53- suspend fun getMenuCollectionName () = withContext(Dispatchers .IO ) {
47+ suspend fun getMenuCollectionNameConfig () = withContext(Dispatchers .IO ) {
48+ val remoteConfig = FirebaseRemoteConfig .getInstance()
49+
5450 if (BuildConfig .DEBUG ) {
5551 remoteConfig.getString(" MENU_COLLECTION_DEV" )
5652 } else {
5753 remoteConfig.getString(" MENU_COLLECTION_PROD" )
5854 }
5955 }
6056
61- fun getFeedbackUrl (): String {
57+ fun getFeedbackUrlConfig (): String {
58+ val remoteConfig = FirebaseRemoteConfig .getInstance()
59+
6260 return if (BuildConfig .DEBUG ) {
6361 remoteConfig.getString(" FEEDBACK_URL_DEV" )
6462 } else {
0 commit comments