Skip to content

Commit 1cdab6d

Browse files
authored
[MERGE] #380 -> develop
[FEAT/#380] 카카오톡 공유하기 / 딥링크 설정
2 parents ad90392 + 9c8f5c3 commit 1cdab6d

18 files changed

Lines changed: 162 additions & 64 deletions

File tree

app/src/main/AndroidManifest.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
android:host="oauth"
3939
android:scheme="kakao${NATIVE_APP_KEY}" />
4040

41-
<data android:host="kakaolink" />
4241
</intent-filter>
4342
</activity>
4443

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
package com.terning.core.designsystem.type
22

3-
enum class NotificationRedirect(val path: String) {
3+
enum class DeeplinkType(val path: String) {
44
CALENDAR("calendar"),
55
HOME("home"),
6-
SEARCH("search");
6+
SEARCH("search"),
7+
KAKAOLINK("kakaolink"),
8+
INTERN("intern");
79

810
companion object {
9-
fun from(type: String?): NotificationRedirect? =
11+
fun from(type: String?): DeeplinkType? =
1012
entries.firstOrNull { it.path.equals(type, ignoreCase = true) }
1113
}
1214
}
Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,24 @@
11
package com.terning.core.designsystem.util
22

3+
import android.net.Uri
4+
35
object DeeplinkDefaults {
6+
private const val SCHEME: String = "terning"
47
const val REDIRECT: String = "redirect"
8+
const val INTERN_ID: String = "internId"
9+
10+
fun build(
11+
host: String,
12+
redirect: String? = null,
13+
internId: String? = null
14+
): String {
15+
val uriBuilder = Uri.Builder()
16+
.scheme(SCHEME)
17+
.authority(host)
18+
19+
redirect?.let { uriBuilder.appendQueryParameter(REDIRECT, it) }
20+
internId?.let { uriBuilder.appendQueryParameter(INTERN_ID, it) }
521

6-
fun build(base: String) = "terning://${base}"
7-
}
22+
return uriBuilder.build().toString()
23+
}
24+
}

core/designsystem/src/main/java/com/terning/core/designsystem/util/KakaoUtil.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ class KakaoUtil @Inject constructor(
3737
} catch (e: Exception) {
3838
Timber.e("웹 공유 실패: ${e.message}")
3939
}
40-
4140
}
4241
}
4342
}

core/firebase/src/main/java/com/terning/core/firebase/messageservice/TerningMessagingService.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@ import com.google.firebase.messaging.FirebaseMessagingService
1616
import com.google.firebase.messaging.RemoteMessage
1717
import com.terning.core.analytics.AmplitudeTracker
1818
import com.terning.core.analytics.EventType
19-
import com.terning.core.designsystem.type.NotificationRedirect
19+
import com.terning.core.designsystem.type.DeeplinkType
2020
import com.terning.core.designsystem.util.DeeplinkDefaults
21-
import com.terning.core.designsystem.util.DeeplinkDefaults.REDIRECT
2221
import com.terning.core.firebase.R
2322
import com.terning.domain.user.repository.UserRepository
2423
import com.terning.navigator.NavigatorProvider
@@ -162,10 +161,10 @@ class TerningMessagingService : FirebaseMessagingService() {
162161
}
163162

164163
private fun buildDeeplink(type: String, isForeground: Boolean): String {
165-
val base = NotificationRedirect.from(type) ?: return ""
164+
val base = DeeplinkType.from(type) ?: return ""
166165

167-
return if (isForeground) DeeplinkDefaults.build(base.path)
168-
else DeeplinkDefaults.build("splash?$REDIRECT=${base.path}")
166+
return if (isForeground) DeeplinkDefaults.build(host = base.path)
167+
else DeeplinkDefaults.build(host = BACKGROUND_HOST, redirect = base.path)
169168
}
170169

171170
companion object {
@@ -174,6 +173,7 @@ class TerningMessagingService : FirebaseMessagingService() {
174173
private const val BODY: String = "body"
175174
private const val TYPE: String = "type"
176175
private const val IMAGE_URL: String = "imageUrl"
176+
private const val BACKGROUND_HOST: String = "splash"
177177
const val FROM_NOTIFICATION: String = "fromNotification"
178178
}
179179
}

feature/home/src/main/java/com/terning/feature/home/HomeRoute.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import androidx.compose.runtime.LaunchedEffect
2222
import androidx.compose.runtime.getValue
2323
import androidx.compose.runtime.mutableStateOf
2424
import androidx.compose.runtime.remember
25+
import androidx.compose.runtime.saveable.rememberSaveable
2526
import androidx.compose.runtime.setValue
2627
import androidx.compose.runtime.snapshotFlow
2728
import androidx.compose.ui.Alignment
@@ -81,6 +82,7 @@ private const val ZERO_TOTAL_COUNT = 0
8182
@OptIn(ExperimentalPermissionsApi::class)
8283
@Composable
8384
fun HomeRoute(
85+
internId: String?,
8486
paddingValues: PaddingValues,
8587
viewModel: HomeViewModel = hiltViewModel(),
8688
navigateToCalendar: () -> Unit,
@@ -103,6 +105,15 @@ fun HomeRoute(
103105
}
104106
}
105107

108+
var hasHandledInternDeeplink by rememberSaveable { mutableStateOf(false) }
109+
110+
LaunchedEffect(internId, hasHandledInternDeeplink) {
111+
if (internId != null && !hasHandledInternDeeplink) {
112+
navigateToIntern(internId.toLong())
113+
hasHandledInternDeeplink = true
114+
}
115+
}
116+
106117
LaunchedEffect(key1 = true) {
107118
viewModel.getProfile()
108119
viewModel.getFilteringInfo()

feature/home/src/main/java/com/terning/feature/home/navigation/HometNavigation.kt renamed to feature/home/src/main/java/com/terning/feature/home/navigation/HomeNavigation.kt

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,19 @@ import androidx.navigation.NavGraphBuilder
88
import androidx.navigation.NavOptions
99
import androidx.navigation.compose.composable
1010
import androidx.navigation.navDeepLink
11+
import androidx.navigation.toRoute
1112
import com.terning.core.designsystem.util.DeeplinkDefaults
1213
import com.terning.core.navigation.MainTabRoute
1314
import com.terning.feature.home.HomeRoute
15+
import kotlinx.serialization.SerialName
1416
import kotlinx.serialization.Serializable
1517

16-
fun NavController.navigateHome(navOptions: NavOptions? = null) {
18+
fun NavController.navigateHome(
19+
internId: String?,
20+
navOptions: NavOptions? = null
21+
) {
1722
navigate(
18-
route = Home,
23+
route = Home(internId),
1924
navOptions = navOptions
2025
)
2126
}
@@ -33,7 +38,9 @@ fun NavGraphBuilder.homeNavGraph(
3338
)
3439
)
3540
) {
41+
val args = it.toRoute<Home>()
3642
HomeRoute(
43+
internId = args.internId,
3744
paddingValues = paddingValues,
3845
navigateToCalendar = navigateToCalendar,
3946
navigateToIntern = navigateToIntern
@@ -42,4 +49,7 @@ fun NavGraphBuilder.homeNavGraph(
4249
}
4350

4451
@Serializable
45-
data object Home : MainTabRoute
52+
data class Home(
53+
@SerialName("internId")
54+
val internId: String? = null
55+
) : MainTabRoute

feature/intern/src/main/java/com/terning/feature/intern/InternRoute.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ fun InternRoute(
8585
navController = navController,
8686
onClickShareButton = {
8787
viewModel.onKakaoShareClicked(
88-
(internState.loadState as UiState.Success).data
88+
(internState.loadState as UiState.Success).data,
89+
announcementId.toString()
8990
)
9091
},
9192
onDismissCancelDialog = {

feature/intern/src/main/java/com/terning/feature/intern/InternViewModel.kt

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import javax.inject.Inject
1919
@HiltViewModel
2020
class InternViewModel @Inject constructor(
2121
private val internRepository: InternRepository,
22-
private val kakaoUtil: KakaoUtil
22+
private val kakaoUtil: KakaoUtil,
2323
) : ViewModel() {
2424

2525
private val _internUiState = MutableStateFlow(InternUiState())
@@ -68,16 +68,24 @@ class InternViewModel @Inject constructor(
6868
}
6969

7070
fun onKakaoShareClicked(
71-
internInfo: InternInfo
71+
internInfo: InternInfo,
72+
announcementId: String,
7273
) {
7374
val templateArgs = mapOf(
7475
"COMPANY_IMG" to internInfo.companyImage,
7576
"TITLE" to internInfo.title,
7677
"DEADLINE" to internInfo.deadline,
7778
"START_DATE" to internInfo.startYearMonth,
7879
"PERIOD" to internInfo.workingPeriod,
79-
"REGI_WEB_DOMAIN" to internInfo.url
80-
)
80+
"A_E" to "kakaolink",
81+
"A_E_D" to "intern",
82+
"I_E" to "kakaolink",
83+
"I_E_D" to "jobDetail",
84+
"redirect" to "intern",
85+
"internId" to announcementId,
86+
"action" to "jobDetail",
87+
"JOB_ID" to announcementId
88+
)
8189
kakaoUtil.shareToKakaoTalk(templateArgs)
8290
}
8391
}

feature/intern/src/main/java/com/terning/feature/intern/InternViewSideEffect.kt

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)