Next cta on Login

This commit is contained in:
rahul bhat
2021-10-07 15:10:37 +05:30
parent 470b33ecfe
commit 76055f93fb
7 changed files with 53 additions and 26 deletions

View File

@@ -97,7 +97,8 @@ object NaviDeepLinkNavigator : DeepLinkListener {
finish: Boolean? = false,
bundle: Bundle = Bundle(),
needsResult: Boolean? = null,
requestCode: Int? = null
requestCode: Int? = null,
clearTask: Boolean? = false
) {
val deepLink = ctaData.url
var intent: Intent? = null
@@ -261,6 +262,11 @@ object NaviDeepLinkNavigator : DeepLinkListener {
intent.putExtras(bundle)
intent.putExtra(Constants.REDIRECT_STATUS, secondIdentifier)
intent.putExtra(Constants.SUB_REDIRECT, thirdIdentifier)
if (clearTask.orFalse()) {
intent.addFlags(
Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP
)
}
if (needsResult.orFalse()) {
activity?.startActivityForResult(intent, requestCode.orZero())
} else activity?.startActivity(intent)
@@ -296,8 +302,7 @@ object NaviDeepLinkNavigator : DeepLinkListener {
finish: Boolean?,
bundle: Bundle?,
needsResult: Boolean?,
requestCode: Int?,
fromDeepLink: Boolean
requestCode: Int?
) {
navigate(activity, ctaData, finish, bundle ?: Bundle(), needsResult, requestCode)
}

View File

@@ -14,7 +14,8 @@ data class OtpRequest(
BuildConfig.VERSION_CODE.toString(),
BuildConfig.VERSION_NAME
),
@SerializedName("deviceDetails") val deviceDetail: DeviceDetail? = null
@SerializedName("deviceDetails") val deviceDetail: DeviceDetail? = null,
@SerializedName("source") val source: String? = null
)
data class AppVersionData(

View File

@@ -1,10 +1,12 @@
package com.naviapp.models.response
import com.google.gson.annotations.SerializedName
import com.navi.common.model.CtaData
data class OtpResponse(
@SerializedName("userId") val userId: String?,
@SerializedName("sessionToken") val sessionToken: String?,
@SerializedName("notificationAuthToken") val authToken: String? = null,
@SerializedName("externalCustomerId") val externalCustomerId: String? = null
@SerializedName("externalCustomerId") val externalCustomerId: String? = null,
@SerializedName("nextCta") val nextCta: CtaData? = null
)

View File

@@ -260,7 +260,8 @@ class OtpFragment : BaseFragment(), View.OnClickListener {
latestOtpToken,
isAutoFetchOtp,
LoginType.OTP.name,
deviceDetail
deviceDetail,
source = arguments?.getString(LOGIN_SOURCE)
)
}
}
@@ -309,7 +310,7 @@ class OtpFragment : BaseFragment(), View.OnClickListener {
companion object {
const val TAG = "OTP_FRAGMENT"
const val OTP_TOKEN = "OTP_TOKEN"
private val CALLER_TYPE = "CALL"
private const val CALLER_TYPE = "CALL"
fun newInstance(source: String?): OtpFragment {
return OtpFragment().apply {
arguments = Bundle().apply {

View File

@@ -20,6 +20,7 @@ import com.google.firebase.auth.FirebaseAuth
import com.navi.amc.investorapp.retrofit.ApiUtils
import com.navi.analytics.firebase.FcmAnalyticsUtil
import com.navi.analytics.utils.NaviTrackEvent
import com.navi.common.model.CtaData
import com.navi.common.sharedpref.PreferenceManager
import com.navi.common.utils.Constants
import com.naviapp.R
@@ -27,6 +28,7 @@ import com.naviapp.analytics.utils.NaviAnalytics
import com.naviapp.analytics.utils.NaviSDKHelper
import com.naviapp.common.BaseActivity
import com.naviapp.common.listeners.FragmentStateListener
import com.naviapp.common.navigator.NaviDeepLinkNavigator
import com.naviapp.common.navigator.ScreenNavigator
import com.naviapp.dashboard.listeners.FragmentInteractionListener
import com.naviapp.databinding.RegistrationActivityBinding
@@ -152,17 +154,6 @@ class RegistrationActivity : BaseActivity(), FragmentInteractionListener, Fragme
}
override fun onActivityCompleted(screen: String?, bundle: Bundle?) {
updateFCMToken()
sendDeviceDetails(applicationContext)
callingActivity?.let {
setResult(Activity.RESULT_OK, intent)
finish()
} ?: run {
ScreenNavigator.instance.startActivityWithNoActivityStack(
this,
ScreenNavigator.DASHBOARD_SCREEN
)
}
}
private fun updateFCMToken() {
@@ -223,7 +214,7 @@ class RegistrationActivity : BaseActivity(), FragmentInteractionListener, Fragme
PreferenceManager.setStringPreference(PHONE_NUMBER, phone)
analyticsTracker.loginWithTrueCaller(phone, source)
showLoader()
registrationVM.loginViaTrueCaller(data)
registrationVM.loginViaTrueCaller(data, source)
}
override fun onVerificationRequired(error: TrueError?) {
@@ -323,7 +314,7 @@ class RegistrationActivity : BaseActivity(), FragmentInteractionListener, Fragme
}
}
hideLoader()
onActivityCompleted()
goToNextScreen(otpResponse.nextCta)
}.addOnFailureListener {
analyticsTracker.trackNotificationAuthTokenSigninFailure()
hideLoader()
@@ -331,6 +322,24 @@ class RegistrationActivity : BaseActivity(), FragmentInteractionListener, Fragme
}
}
private fun goToNextScreen(nextCta: CtaData?) {
updateFCMToken()
sendDeviceDetails(applicationContext)
nextCta?.let { cta ->
NaviDeepLinkNavigator.navigate(this, cta, true, clearTask = true)
} ?: run {
callingActivity?.let {
setResult(Activity.RESULT_OK, intent)
finish()
} ?: run {
ScreenNavigator.instance.startActivityWithNoActivityStack(
this,
ScreenNavigator.DASHBOARD_SCREEN
)
}
}
}
private fun updateCommunicationMediums() {
val whatsappEnabled = PreferenceManager.getBooleanPreference(WHATSAPP_COMMUNICATION_ENABLED)
val eventTracker = NaviAnalytics.naviAnalytics.Whatsapp()

View File

@@ -123,10 +123,18 @@ class RegistrationVM : BaseVM() {
otpToken: String,
isAutoFetchOtp: Boolean,
loginType: String,
deviceDetail: DeviceDetail
deviceDetail: DeviceDetail,
source: String?
) {
val otpRequest =
OtpRequest(otp, otpToken, isAutoFetchOtp, loginType, deviceDetail = deviceDetail)
OtpRequest(
otp,
otpToken,
isAutoFetchOtp,
loginType,
deviceDetail = deviceDetail,
source = source
)
coroutineScope.launch {
val response = registerRepository.verifyOtp(otpRequest)
Timber.i("otp data $response")
@@ -155,12 +163,13 @@ class RegistrationVM : BaseVM() {
}
}
fun loginViaTrueCaller(data: TrueProfileData) {
fun loginViaTrueCaller(data: TrueProfileData, source: String?) {
coroutineScope.launch {
val response = registerRepository.verifyOtp(
OtpRequest(
truecallerProfileData = data,
loginType = LoginType.TRUE_CALLER.name
loginType = LoginType.TRUE_CALLER.name,
source = source
)
)
when {
@@ -186,6 +195,7 @@ class RegistrationVM : BaseVM() {
}
}
// if we are using this in future, add source in request.
fun trueCallerDropCall(data: TrueCallerDropCallData) {
coroutineScope.launch {
val response = registerRepository.trueCallerDropCall(data)

View File

@@ -11,7 +11,6 @@ interface DeepLinkListener {
finish: Boolean?,
bundle: Bundle?,
needsResult: Boolean? = null,
requestCode: Int? = null,
fromDeepLink: Boolean = false
requestCode: Int? = null
)
}