diff --git a/android/app/src/main/java/com/naviapp/common/navigator/NaviDeepLinkNavigator.kt b/android/app/src/main/java/com/naviapp/common/navigator/NaviDeepLinkNavigator.kt
index de4d00b53e..b5781d0686 100644
--- a/android/app/src/main/java/com/naviapp/common/navigator/NaviDeepLinkNavigator.kt
+++ b/android/app/src/main/java/com/naviapp/common/navigator/NaviDeepLinkNavigator.kt
@@ -139,6 +139,7 @@ import com.naviapp.utils.NaviDownloadManager
import com.naviapp.utils.deleteCacheAndOpenLoginPage
import com.naviapp.utils.openPlayStore
import com.naviapp.utils.openWhatsAppChatConversation
+import com.naviapp.webredirection.presentation.utils.BUSINESS_UNIT
import com.naviapp.webredirection.presentation.utils.WEB_PLATFORM_IDENTIFIER
import com.naviapp.webredirection.presentation.utils.WEB_REDIRECTION_SUBTITLE
import com.naviapp.webredirection.presentation.utils.WEB_REDIRECTION_TITLE
@@ -742,7 +743,10 @@ object NaviDeepLinkNavigator : DeepLinkListener {
ctaData.parameters
?.firstOrNull { it.key == WEB_PLATFORM_IDENTIFIER }
?.value
- intent = getWebRedirectionIntent(activity, webPlatformIdentifier)
+ val businessUnit =
+ ctaData.parameters?.firstOrNull { it.key == BUSINESS_UNIT }?.value
+ intent =
+ getWebRedirectionIntent(activity, webPlatformIdentifier, businessUnit)
}
CREDIT_CARD_DETAILS -> {
intent = Intent(activity, CreditCardAdDetailsActivity::class.java)
diff --git a/android/app/src/main/java/com/naviapp/webredirection/presentation/utils/Constants.kt b/android/app/src/main/java/com/naviapp/webredirection/presentation/utils/Constants.kt
index 3be2e1b3d7..3985de2a1b 100644
--- a/android/app/src/main/java/com/naviapp/webredirection/presentation/utils/Constants.kt
+++ b/android/app/src/main/java/com/naviapp/webredirection/presentation/utils/Constants.kt
@@ -28,6 +28,7 @@ const val WEB_REDIRECTION_DELAY_IN_MILLIS = "webRedirectionDelayInMillis"
const val TIME_TAKEN = "timeTaken"
const val DATA_PROCESSED = "dataProcessed"
const val BUSINESS_UNIT = "businessUnit"
+const val CRM_BUSINESS_UNIT = "CRM"
const val WEB_REDIRECTION_FIRST_LAUNCH_TIMESTAMP = "web_redirection_first_launch_timestamp"
const val WEB_REDIRECTION_FIRST_LAUNCH = "redirection_to_web_first_launch"
const val WEB_REDIRECTION_SUBSEQUENT_LAUNCH = "redirection_to_web_subsequent_launch"
diff --git a/android/app/src/main/java/com/naviapp/webredirection/presentation/utils/Utils.kt b/android/app/src/main/java/com/naviapp/webredirection/presentation/utils/Utils.kt
index 933ce21984..6e2ae6eff9 100644
--- a/android/app/src/main/java/com/naviapp/webredirection/presentation/utils/Utils.kt
+++ b/android/app/src/main/java/com/naviapp/webredirection/presentation/utils/Utils.kt
@@ -12,6 +12,7 @@ import android.content.Intent
import com.navi.analytics.utils.NaviTrackEvent
import com.navi.base.sharedpref.PreferenceManager
import com.navi.base.utils.orFalse
+import com.navi.chat.ui.activities.CRMWebViewActivity
import com.navi.common.firebaseremoteconfig.FirebaseRemoteConfigHelper
import com.navi.common.firebaseremoteconfig.FirebaseRemoteConfigHelper.WEB_REDIRECTION_DEFAULT_DELAY_IN_MILLIS
import com.navi.common.firebaseremoteconfig.FirebaseRemoteConfigHelper.WEB_REDIRECTION_SMS_UPLOADED_DELAY_IN_MILLIS
@@ -60,11 +61,21 @@ fun calculateRedirectDelayForSmsUpload(
}
}
-fun getWebRedirectionIntent(sourceActivity: Activity?, identifier: String? = null): Intent {
+fun getWebRedirectionIntent(
+ sourceActivity: Activity?,
+ identifier: String? = null,
+ businessUnit: String? = null,
+): Intent {
if (sourceActivity == null) return Intent()
-
if (identifier == null) {
- return Intent(sourceActivity, WebRedirectionActivity::class.java)
+ return when (businessUnit) {
+ CRM_BUSINESS_UNIT -> {
+ Intent(sourceActivity, CRMWebViewActivity::class.java)
+ }
+ else -> {
+ Intent(sourceActivity, WebRedirectionActivity::class.java)
+ }
+ }
}
NaviTrackEvent.trackEvent(
eventName = WEB_TAB_REDIRECTION_INTENT,
diff --git a/android/navi-chat/src/main/AndroidManifest.xml b/android/navi-chat/src/main/AndroidManifest.xml
index 4d41e13bd6..065310d37f 100644
--- a/android/navi-chat/src/main/AndroidManifest.xml
+++ b/android/navi-chat/src/main/AndroidManifest.xml
@@ -56,6 +56,7 @@
diff --git a/android/navi-chat/src/main/java/com/navi/chat/models/WebViewIntent.kt b/android/navi-chat/src/main/java/com/navi/chat/models/WebViewIntent.kt
index a1f776d755..36e56e9ab9 100644
--- a/android/navi-chat/src/main/java/com/navi/chat/models/WebViewIntent.kt
+++ b/android/navi-chat/src/main/java/com/navi/chat/models/WebViewIntent.kt
@@ -14,5 +14,9 @@ data class WebViewIntent(
val productType: String?,
val fromActiveChat: Boolean? = false,
val conversationId: String? = null,
+ val webBaseUrl: String? = null,
+ val webBasePath: String? = null,
+ val continueUrl: String? = null,
+ val continuePath: String? = null,
val dataSource: String? = null,
)
diff --git a/android/navi-chat/src/main/java/com/navi/chat/ui/activities/CRMWebViewActivity.kt b/android/navi-chat/src/main/java/com/navi/chat/ui/activities/CRMWebViewActivity.kt
index 4d0fb651b5..6d1e67fd0c 100644
--- a/android/navi-chat/src/main/java/com/navi/chat/ui/activities/CRMWebViewActivity.kt
+++ b/android/navi-chat/src/main/java/com/navi/chat/ui/activities/CRMWebViewActivity.kt
@@ -48,6 +48,10 @@ import com.navi.chat.utils.PL_WEB_URL_HOST_NAME
import com.navi.chat.utils.PRODUCT_TYPE
import com.navi.chat.utils.SCREEN_NAME
import com.navi.chat.utils.SCREEN_NAME_CAPITAL
+import com.navi.chat.utils.WEB_BASE_PATH
+import com.navi.chat.utils.WEB_BASE_URL
+import com.navi.chat.utils.WEB_CONTINUE_PATH
+import com.navi.chat.utils.WEB_CONTINUE_URL
import com.navi.chat.viewmodels.CRMWebSharedViewModel
import com.navi.common.firebaseremoteconfig.FirebaseRemoteConfigHelper
import com.navi.common.model.ModuleNameV2
@@ -77,39 +81,29 @@ class CRMWebViewActivity : BaseActivity() {
@SuppressLint("SetJavaScriptEnabled", "JavascriptInterface")
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
-
setContentView(com.navi.common.R.layout.activity_navi_web_view)
webView = findViewById(com.navi.common.R.id.web_view)
setupWebView(webView)
-
val configId =
intent.getStringExtra(SCREEN_NAME)
?: intent.getStringExtra(SCREEN_NAME_CAPITAL)
?: intent.getStringExtra(CHAT_BOT_SCREEN_NAME)
-
- val fromActiveChat = intent.getStringExtra(ACTIVE_CHAT_CONV)
- val conversationId = intent.getStringExtra(CONVERSATION_ID_PARAM)
- webViewIntent =
- WebViewIntent(
- naviClickActionUrl = intent.getStringExtra(NAVI_CLICK_ACTION_URL),
- configId = configId,
- orderId = intent.getStringExtra(ORDER_ID),
- productType = intent.getStringExtra(PRODUCT_TYPE),
- fromActiveChat = fromActiveChat.toBoolean(),
- conversationId = conversationId,
- dataSource = intent.getStringExtra(DATA_SOURCE),
- )
- pathUrl = viewModel.buildPathUrl(webViewIntent)
-
+ initWebIntentData()
if (
- pathUrl.isNullOrEmpty() ||
- (webViewIntent?.naviClickActionUrl != ALL_TICKETS_V2 &&
- webViewIntent?.configId.isNullOrEmpty())
+ webViewIntent?.webBaseUrl.isNullOrEmpty() &&
+ webViewIntent?.continueUrl.isNullOrEmpty() &&
+ (pathUrl.isNullOrEmpty() ||
+ (webViewIntent?.naviClickActionUrl != ALL_TICKETS_V2 &&
+ webViewIntent?.configId.isNullOrEmpty()))
) {
viewModel.showError.value = true
} else {
viewModel.showLoader.value = false
- viewModel.getCrmWebViewUrl(pathUrl = pathUrl.toString(), naeScreenName = screenName)
+ viewModel.getCrmWebViewUrl(
+ pathUrl = pathUrl.toString(),
+ naeScreenName = screenName,
+ webViewIntent = webViewIntent,
+ )
}
initObservers()
@@ -127,6 +121,34 @@ class CRMWebViewActivity : BaseActivity() {
)
}
+ private fun initWebIntentData() {
+ val configId =
+ intent.getStringExtra(SCREEN_NAME)
+ ?: intent.getStringExtra(SCREEN_NAME_CAPITAL)
+ ?: intent.getStringExtra(CHAT_BOT_SCREEN_NAME)
+ val fromActiveChat = intent.getStringExtra(ACTIVE_CHAT_CONV)
+ val conversationId = intent.getStringExtra(CONVERSATION_ID_PARAM)
+ val webBaseUrl = intent.getStringExtra(WEB_BASE_URL)
+ val webContinueUrl = intent.getStringExtra(WEB_CONTINUE_URL)
+ val webContinuePath = intent.getStringExtra(WEB_CONTINUE_PATH)
+ val webBasePath = intent.getStringExtra(WEB_BASE_PATH)
+ webViewIntent =
+ WebViewIntent(
+ naviClickActionUrl = intent.getStringExtra(NAVI_CLICK_ACTION_URL),
+ configId = configId,
+ orderId = intent.getStringExtra(ORDER_ID),
+ productType = intent.getStringExtra(PRODUCT_TYPE),
+ fromActiveChat = fromActiveChat.toBoolean(),
+ conversationId = conversationId,
+ webBaseUrl = webBaseUrl,
+ continueUrl = webContinueUrl,
+ webBasePath = webBasePath,
+ continuePath = webContinuePath,
+ dataSource = intent.getStringExtra(DATA_SOURCE),
+ )
+ pathUrl = viewModel.buildPathUrl(webViewIntent)
+ }
+
private fun initObservers() {
viewModel.webViewUrl.observe(this) { url -> url?.let { webView.loadUrl(it) } }
@@ -267,6 +289,17 @@ class CRMWebViewActivity : BaseActivity() {
blockNotification = false
}
+ override fun onNewIntent(intent: Intent) {
+ super.onNewIntent(intent)
+ viewModel.showLoader.value = true
+ initWebIntentData()
+ viewModel.getCrmWebViewUrl(
+ pathUrl = pathUrl.toString(),
+ naeScreenName = screenName,
+ webViewIntent = webViewIntent,
+ )
+ }
+
private fun updateBlockNotification(value: Boolean) {
blockNotification = value
}
diff --git a/android/navi-chat/src/main/java/com/navi/chat/utils/ChatNavigator.kt b/android/navi-chat/src/main/java/com/navi/chat/utils/ChatNavigator.kt
index 5bd1ce1f10..c74bb742cd 100644
--- a/android/navi-chat/src/main/java/com/navi/chat/utils/ChatNavigator.kt
+++ b/android/navi-chat/src/main/java/com/navi/chat/utils/ChatNavigator.kt
@@ -9,6 +9,7 @@ package com.navi.chat.utils
import android.app.Activity
import android.content.Intent
+import android.content.Intent.FLAG_ACTIVITY_CLEAR_TOP
import android.os.Bundle
import com.navi.chat.ui.activities.CRMWebViewActivity
import com.navi.chat.ui.activities.NaviChatActivity
@@ -44,13 +45,16 @@ fun getCrmWebViewIntent(
putExtra(NAVI_CLICK_ACTION_URL, ctaUrl)
putExtra(ACTIVE_CHAT_CONV, fromActiveChat)
putExtra(CONVERSATION_ID_PARAM, conversationId)
+ flags = FLAG_ACTIVITY_CLEAR_TOP
}
}
fun navigateToCrm(activity: Activity?, bundle: Bundle?, path: String?) {
val intent =
if (FirebaseRemoteConfigHelper.getBoolean(CRM_WEB_VIEW_ENABLED, true)) {
- Intent(activity, CRMWebViewActivity::class.java)
+ Intent(activity, CRMWebViewActivity::class.java).apply {
+ flags = FLAG_ACTIVITY_CLEAR_TOP
+ }
} else {
when (path) {
PRODUCT_HELP_PAGE -> Intent(activity, SupportScreenActivity::class.java)
diff --git a/android/navi-chat/src/main/java/com/navi/chat/utils/Constants.kt b/android/navi-chat/src/main/java/com/navi/chat/utils/Constants.kt
index 11beca76b1..c3db33afac 100644
--- a/android/navi-chat/src/main/java/com/navi/chat/utils/Constants.kt
+++ b/android/navi-chat/src/main/java/com/navi/chat/utils/Constants.kt
@@ -80,6 +80,10 @@ const val BOT = "BOT"
const val DIGITAL_GOLD = "DIGITAL_GOLD"
const val FILENAME = "filename"
const val NODE_UUID_PARAM = "nodeUuid"
+const val WEB_BASE_URL = "WEB_BASE_URL"
+const val WEB_BASE_PATH = "WEB_BASE_PATH"
+const val WEB_CONTINUE_PATH = "WEB_CONTINUE_PATH"
+const val WEB_CONTINUE_URL = "continue"
/* Video Player Instance Save Constant */
const val CURRENT_VIDEO_POSITION_IN_MS = "currentVideoPositionInMs"
diff --git a/android/navi-chat/src/main/java/com/navi/chat/viewmodels/CRMWebSharedViewModel.kt b/android/navi-chat/src/main/java/com/navi/chat/viewmodels/CRMWebSharedViewModel.kt
index 9de3728ac9..57888a7f0b 100644
--- a/android/navi-chat/src/main/java/com/navi/chat/viewmodels/CRMWebSharedViewModel.kt
+++ b/android/navi-chat/src/main/java/com/navi/chat/viewmodels/CRMWebSharedViewModel.kt
@@ -91,7 +91,11 @@ constructor(
val showError: MutableLiveData
get() = _showError
- fun getCrmWebViewUrl(pathUrl: String, naeScreenName: String) {
+ fun getCrmWebViewUrl(
+ pathUrl: String,
+ naeScreenName: String,
+ webViewIntent: WebViewIntent? = null,
+ ) {
viewModelScope.safeLaunch(Dispatchers.IO) {
val codeVerifier = generateRandomString(32)
val codeChallenger = generateSHA256Hash(codeVerifier)
@@ -114,15 +118,21 @@ constructor(
codeVerifier = codeVerifier,
token = it.data?.code.toString(),
pathUrl = pathUrl,
+ webViewIntent = webViewIntent,
)
}
-
+ _showLoader.postValue(false)
_showError.postValue(crmWebViewUrl.isNullOrEmpty())
_webViewUrl.postValue(crmWebViewUrl)
}
}
- private fun buildCrmWebViewUrl(codeVerifier: String, token: String, pathUrl: String): String {
+ private fun buildCrmWebViewUrl(
+ codeVerifier: String,
+ token: String,
+ pathUrl: String,
+ webViewIntent: WebViewIntent? = null,
+ ): String {
val urlParamsMap: MutableMap =
mutableMapOf(
Pair(
@@ -149,16 +159,20 @@ constructor(
Pair(APP_VERSION_CODE, CommonLibManager.buildConfigDetails.appVersionCode),
Pair(
CONTINUE,
- FirebaseRemoteConfigHelper.getString(
- CRM_WEB_VIEW_URL_PARAM_CONTINUE,
- defaultValue = CUSTOMER_SUPPORT_PATH,
- ) + pathUrl,
+ if (webViewIntent?.continueUrl.isNotNullAndNotEmpty()) pathUrl
+ else
+ FirebaseRemoteConfigHelper.getString(
+ CRM_WEB_VIEW_URL_PARAM_CONTINUE,
+ defaultValue = CUSTOMER_SUPPORT_PATH,
+ ) + pathUrl,
),
)
val baseUrl =
- FirebaseRemoteConfigHelper.getString(CRM_WEB_VIEW_BASE_URL, EMPTY) + AUTOLOGIN_PATH
+ if (webViewIntent != null && webViewIntent.webBaseUrl.isNotNullAndNotEmpty())
+ webViewIntent.webBaseUrl
+ else FirebaseRemoteConfigHelper.getString(CRM_WEB_VIEW_BASE_URL, EMPTY) + AUTOLOGIN_PATH
return buildUrlWithParameters(
- baseUrl,
+ baseUrl!!,
urlParamsMap.filter { it.value.isNotNullAndNotEmpty() },
)
}
@@ -169,16 +183,24 @@ constructor(
webViewIntent.configId.isNullOrEmpty() ||
webViewIntent.naviClickActionUrl.isNullOrEmpty()
) {
- if (webViewIntent != null && webViewIntent.naviClickActionUrl == ALL_TICKETS_V2) {
- _showError.postValue(false)
- } else {
+ if (webViewIntent == null) {
_showError.postValue(true)
return EMPTY
}
+ if (webViewIntent.naviClickActionUrl == ALL_TICKETS_V2) {
+ _showError.postValue(false)
+ } else {
+ if (webViewIntent.continueUrl.isNullOrEmpty()) {
+ _showError.postValue(true)
+ return EMPTY
+ }
+ }
}
val pathUrl =
- if (
+ if (webViewIntent.continueUrl.isNotNullAndNotEmpty())
+ StringBuilder().append(webViewIntent.continueUrl)
+ else if (
(webViewIntent.fromActiveChat == true ||
webViewIntent.naviClickActionUrl == CHAT_ACTIVITY) &&
webViewIntent.configId != null