NotificationUtil: Navigate through splash fragment for updates notification

AuthData can get expired by the time a user clicks on the update notification.
Navigating through splash fragment will ensure required checks being ran.

Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
Aayush Gupta
2024-11-14 12:15:09 +03:00
parent 44d20d517d
commit e35f716e14
2 changed files with 9 additions and 2 deletions

View File

@@ -201,8 +201,9 @@ object NotificationUtil {
fun getUpdateNotification(context: Context, updatesList: List<Update>): Notification { fun getUpdateNotification(context: Context, updatesList: List<Update>): Notification {
val contentIntent = NavDeepLinkBuilder(context) val contentIntent = NavDeepLinkBuilder(context)
.setGraph(R.navigation.mobile_navigation) .setGraph(R.navigation.mobile_navigation)
.setDestination(R.id.updatesFragment) .setDestination(R.id.splashFragment)
.setComponentName(MainActivity::class.java) .setComponentName(MainActivity::class.java)
.setArguments(bundleOf("destinationId" to R.id.updatesFragment))
.createPendingIntent() .createPendingIntent()
return NotificationCompat.Builder(context, Constants.NOTIFICATION_CHANNEL_UPDATES) return NotificationCompat.Builder(context, Constants.NOTIFICATION_CHANNEL_UPDATES)

View File

@@ -194,8 +194,14 @@ class SplashFragment : BaseFragment<FragmentSplashBinding>() {
} }
private fun navigateToDefaultTab() { private fun navigateToDefaultTab() {
val defaultDestination = Preferences.getInteger(requireContext(), PREFERENCE_DEFAULT_SELECTED_TAB)
val directions = val directions =
when (Preferences.getInteger(requireContext(), PREFERENCE_DEFAULT_SELECTED_TAB)) { when (requireArguments().getInt("destinationId", defaultDestination)) {
R.id.updatesFragment -> {
requireArguments().remove("destinationId")
SplashFragmentDirections.actionSplashFragmentToUpdatesFragment()
}
1 -> SplashFragmentDirections.actionSplashFragmentToGamesContainerFragment() 1 -> SplashFragmentDirections.actionSplashFragmentToGamesContainerFragment()
2 -> SplashFragmentDirections.actionSplashFragmentToUpdatesFragment() 2 -> SplashFragmentDirections.actionSplashFragmentToUpdatesFragment()
else -> SplashFragmentDirections.actionSplashFragmentToNavigationApps() else -> SplashFragmentDirections.actionSplashFragmentToNavigationApps()