Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

푸시 알림 딥링크 #170

Merged
merged 3 commits into from
Jun 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ object NavigationDestination {
const val LecturesOfTable = "lectures_of_table"
const val LectureDetail = "lecture_detail"
const val LectureColorSelector = "lecture_color_selector"
const val Notification = "notification"
const val Notification = "notifications"
const val AppReport = "app_report"
const val ServiceInfo = "service_info"
const val TeamInfo = "team_info"
Expand Down
16 changes: 16 additions & 0 deletions app/src/main/java/com/wafflestudio/snutt2/views/RootActivity.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.wafflestudio.snutt2.views

import android.animation.ObjectAnimator
import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.view.View
Expand All @@ -21,7 +22,9 @@ import androidx.hilt.navigation.compose.hiltViewModel
import androidx.lifecycle.lifecycleScope
import androidx.navigation.NavBackStackEntry
import androidx.navigation.NavController
import androidx.navigation.NavDeepLink
import androidx.navigation.NavGraphBuilder
import androidx.navigation.navDeepLink
import com.google.accompanist.navigation.animation.AnimatedNavHost
import com.google.accompanist.navigation.animation.composable
import com.google.accompanist.navigation.animation.navigation
Expand Down Expand Up @@ -72,6 +75,7 @@ class RootActivity : AppCompatActivity() {

super.onCreate(savedInstanceState)
setContentView(R.layout.activity_root)
parseDeeplinkExtra()

lifecycleScope.launch {
homeViewModel.refreshData()
Expand Down Expand Up @@ -234,10 +238,12 @@ class RootActivity : AppCompatActivity() {

private fun NavGraphBuilder.composable2(
route: String,
deepLinks: List<NavDeepLink> = listOf(navDeepLink { uriPattern = "${applicationContext.getString(R.string.scheme)}$route" }),
content: @Composable AnimatedVisibilityScope.(NavBackStackEntry) -> Unit
) {
composable(
route,
deepLinks = deepLinks,
enterTransition = {
slideInHorizontally(
initialOffsetX = { fullWidth -> fullWidth },
Expand Down Expand Up @@ -290,6 +296,16 @@ class RootActivity : AppCompatActivity() {
}
}
}

private fun parseDeeplinkExtra() {
intent.extras?.getString(URL_SCHEME)?.let {
intent.data = Uri.parse(it)
Copy link
Collaborator Author

@JuTaK97 JuTaK97 May 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

앞으로 딥링크 외에도 푸시알림에 들어있는 정보는 모두 여기서 처리하기

}
}

companion object {
const val URL_SCHEME = "url_scheme"
}
}

fun NavController.navigateAsOrigin(route: String) {
Expand Down
Loading