@@ -10,6 +10,7 @@ import androidx.lifecycle.lifecycleScope
10
10
import androidx.navigation.NavController
11
11
import androidx.navigation.fragment.findNavController
12
12
import androidx.navigation.ui.setupWithNavController
13
+ import com.velogm.presentation.BuildConfig
13
14
import com.google.firebase.ktx.Firebase
14
15
import com.google.firebase.remoteconfig.FirebaseRemoteConfig
15
16
import com.google.firebase.remoteconfig.ktx.remoteConfig
@@ -36,15 +37,7 @@ class MainActivity : BindingActivity<ActivityMainBinding>(R.layout.activity_main
36
37
initView()
37
38
setupLogoutState()
38
39
setUpWithdrawalState()
39
-
40
- remoteConfig = Firebase .remoteConfig
41
-
42
- val configSettings = remoteConfigSettings {
43
- minimumFetchIntervalInSeconds = 0
44
- }
45
-
46
- remoteConfig.setConfigSettingsAsync(configSettings)
47
-
40
+ setRemoteConfig()
48
41
fetchAppVersion()
49
42
}
50
43
@@ -110,26 +103,31 @@ class MainActivity : BindingActivity<ActivityMainBinding>(R.layout.activity_main
110
103
111
104
}
112
105
}
113
- private fun fetchAppVersion () {
114
- // val appVersion = remoteConfig[REMOTE_KEY_APP_VERSION].asString()
115
- var appVersion= " 0.0.0"
116
- Timber .tag(" remote config1" ).d(" $appVersion " )
117
- appVersion= remoteConfig.getString(REMOTE_KEY_APP_VERSION )
118
- Timber .tag(" remote config2" ).d(" $appVersion " )
119
106
120
- AlertDialog .Builder (this )
121
- .setTitle(" Remote Config" )
122
- .setMessage(" App version :: $appVersion " )
123
- .show()
107
+ private fun setRemoteConfig () {
108
+ remoteConfig = Firebase .remoteConfig
109
+ val configSettings = remoteConfigSettings {
110
+ minimumFetchIntervalInSeconds = 1800
111
+ }
112
+ remoteConfig.setConfigSettingsAsync(configSettings)
113
+ }
114
+
115
+ private fun fetchAppVersion () {
116
+ var appVersion = remoteConfig.getString(REMOTE_KEY_APP_VERSION )
124
117
125
118
remoteConfig.fetchAndActivate()
126
119
.addOnCompleteListener {
127
120
if (it.isSuccessful) {
128
- Timber .tag(" remoteConfig" ).d(" success" )
129
- // fetch and activate 성공
121
+ if (appVersion.equals(BuildConfig .VERSION_NAMES ))
122
+ Timber .tag(" remoteConfig" ).d(" ${BuildConfig .VERSION_NAMES } " )
123
+ else {
124
+ AlertDialog .Builder (this )
125
+ .setTitle(" Alert Version" )
126
+ .setMessage(" 새로운 ${appVersion} 이 출시했습니다." )
127
+ .show()
128
+ }
130
129
} else {
131
130
Timber .tag(" remoteConfig" ).d(" fail" )
132
- // fetch and activate 실패
133
131
}
134
132
}
135
133
}
0 commit comments