NTP-8809 | Update remote config from silent PN (#14112)

This commit is contained in:
Abhinav Gupta
2024-12-12 18:29:14 +05:30
committed by GitHub
parent fa0d6313c0
commit dbbcbd7c62
3 changed files with 33 additions and 0 deletions

View File

@@ -32,6 +32,7 @@ import com.navi.base.utils.orFalse
import com.navi.chat.ui.activities.NaviChatActivity
import com.navi.chat.utils.CHAT_PN_RECEIVED
import com.navi.common.dbcleaner.ModuleDatabaseCleanerExecutor
import com.navi.common.firebaseremoteconfig.FirebaseRemoteConfigHelper
import com.navi.common.model.ModuleName
import com.navi.common.preferences.NaviPreferenceCleanerExecutor
import com.navi.common.pushnotification.CustomNotificationHandler
@@ -220,6 +221,9 @@ class NaviFirebaseMessagingService : FirebaseMessagingService() {
columnName = data[NotificationConstants.COLUMN_NAME].orEmpty()
)
}
NotificationConstants.UPDATE_REMOTE_CONFIG -> {
FirebaseRemoteConfigHelper.updateRemoteConfigForcefully()
}
}
NaviTrackEvent.trackEventOnClickStream(
Constants.SILENT_PN_ACTION,

View File

@@ -229,6 +229,10 @@ object FirebaseRemoteConfigHelper {
private const val FIREBASE_REMOTE_CONFIG_FETCH_FAILED =
"dev_FIREBASE_REMOTE_CONFIG_FETCH_FAILED"
const val APP_SETTINGS_IN_APP_HANDLER_ENABLED = "APP_SETTINGS_IN_APP_HANDLER_ENABLED"
private const val FIREBASE_REMOTE_CONFIG_FORCE_FETCH_SUCCESS =
"dev_FIREBASE_REMOTE_CONFIG_FORCE_FETCH_SUCCESS"
private const val FIREBASE_REMOTE_CONFIG_FORCE_FETCH_FAILED =
"dev_FIREBASE_REMOTE_CONFIG_FORCE_FETCH_FAILED"
// CRM
const val CRM_WEB_VIEW_ENABLED = "CRM_WEB_VIEW_ENABLED"
@@ -265,6 +269,30 @@ object FirebaseRemoteConfigHelper {
return remoteConfig
}
/**
* Forces a fetch of the remote configuration, ignoring the minimum fetch interval.
*
* @param minimumFetchIntervalInSeconds The time interval in seconds since the last fetch, which
* is ignored in this forced fetch (set to 0 for immediate backend fetch).
*/
fun updateRemoteConfigForcefully() {
remoteConfig.fetch(0).addOnCompleteListener { task ->
if (task.isSuccessful) {
remoteConfig.activate().addOnCompleteListener {
NaviTrackEvent.trackEvent(FIREBASE_REMOTE_CONFIG_FORCE_FETCH_SUCCESS)
}
} else {
NaviTrackEvent.trackEvent(
eventName = FIREBASE_REMOTE_CONFIG_FORCE_FETCH_FAILED,
eventValues =
mapOf(
ERROR to (task.exception?.toJsonObject().toString()),
),
)
}
}
}
private fun getRawValue(forKey: String): FirebaseRemoteConfigValue? {
return try {
val rawValue = remoteConfig.getValue(forKey)

View File

@@ -48,6 +48,7 @@ object NotificationConstants {
const val PREFERENCE_TYPE = "preference_type"
const val ACTION_CLEAN_PREFERENCE_KEYS = "actionCleanPreferenceKeys"
const val ACTION_CLEAN_DATABASE_MODULE_TABLE_KEYS = "actionCleanDatabaseModuleTableKeys"
const val UPDATE_REMOTE_CONFIG = "updateRemoteConfig"
const val DB_NAME = "db_name"
const val TABLE_NAME = "table_name"
const val MODULE_NAME = "module_name"