딥링크만 처리하는 액티비티 추가
This commit is contained in:
parent
c5e60785da
commit
b39857cf24
|
@ -66,13 +66,8 @@
|
|||
android:usesCleartextTraffic="true"
|
||||
tools:targetApi="31">
|
||||
<activity
|
||||
android:name=".splash.SplashActivity"
|
||||
android:name=".main.DeepLinkActivity"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
<intent-filter android:autoVerify="true">
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
|
||||
|
@ -92,6 +87,15 @@
|
|||
<data android:scheme="${URISCHEME}" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".splash.SplashActivity"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity android:name=".main.MainActivity" />
|
||||
<activity android:name=".user.login.LoginActivity" />
|
||||
<activity android:name=".user.signup.SignUpActivity" />
|
||||
|
|
|
@ -6,7 +6,6 @@ import android.content.pm.PackageManager
|
|||
import android.os.Build
|
||||
import androidx.appcompat.app.AppCompatDelegate
|
||||
import com.appsflyer.AppsFlyerLib
|
||||
import com.appsflyer.deeplink.DeepLinkResult
|
||||
import com.facebook.FacebookSdk
|
||||
import com.orhanobut.logger.AndroidLogAdapter
|
||||
import com.orhanobut.logger.Logger
|
||||
|
@ -59,54 +58,8 @@ class SodaLiveApp : Application() {
|
|||
}
|
||||
|
||||
private fun setupAppsFlyer() {
|
||||
clearDeferredDeepLink()
|
||||
|
||||
// Appsflyer SDK 초기화
|
||||
AppsFlyerLib.getInstance().init("tWF2wbJ5nSkya5Ru9mGcPU", null, this)
|
||||
AppsFlyerLib.getInstance().start(this)
|
||||
|
||||
// 딥링크 및 디퍼드 딥링크 처리
|
||||
AppsFlyerLib.getInstance().subscribeForDeepLink { deepLinkResult ->
|
||||
when (deepLinkResult.status) {
|
||||
DeepLinkResult.Status.FOUND -> {
|
||||
val deepLink = deepLinkResult.deepLink
|
||||
SharedPreferenceManager.marketingLinkValue = deepLink?.getStringValue(
|
||||
"deep_link_value"
|
||||
) ?: ""
|
||||
|
||||
val marketingPid = deepLink?.getStringValue(
|
||||
"deep_link_sub1"
|
||||
)
|
||||
|
||||
if (marketingPid != null) {
|
||||
SharedPreferenceManager.marketingPid = marketingPid
|
||||
}
|
||||
|
||||
SharedPreferenceManager.marketingUtmSource = deepLink?.getStringValue(
|
||||
"deep_link_sub2"
|
||||
) ?: ""
|
||||
SharedPreferenceManager.marketingUtmMedium = deepLink?.getStringValue(
|
||||
"deep_link_sub3"
|
||||
) ?: ""
|
||||
SharedPreferenceManager.marketingUtmCampaign = deepLink?.getStringValue(
|
||||
"deep_link_sub4"
|
||||
) ?: ""
|
||||
SharedPreferenceManager.marketingLinkValueId = deepLink?.getStringValue(
|
||||
"deep_link_sub5"
|
||||
)?.toLongOrNull() ?: 0L
|
||||
}
|
||||
|
||||
DeepLinkResult.Status.NOT_FOUND -> Logger.d("딥링크를 찾을 수 없습니다.")
|
||||
DeepLinkResult.Status.ERROR -> Logger.d("딥링크 처리 중 오류 발생: ${deepLinkResult.error}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun clearDeferredDeepLink() {
|
||||
SharedPreferenceManager.marketingUtmSource = ""
|
||||
SharedPreferenceManager.marketingUtmMedium = ""
|
||||
SharedPreferenceManager.marketingUtmCampaign = ""
|
||||
SharedPreferenceManager.marketingLinkValue = ""
|
||||
SharedPreferenceManager.marketingLinkValueId = 0
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
package kr.co.vividnext.sodalive.main
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.appsflyer.AppsFlyerLib
|
||||
import com.appsflyer.deeplink.DeepLinkResult
|
||||
import com.orhanobut.logger.Logger
|
||||
import kr.co.vividnext.sodalive.common.SharedPreferenceManager
|
||||
import kr.co.vividnext.sodalive.splash.SplashActivity
|
||||
|
||||
class DeepLinkActivity : AppCompatActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
// 딥링크 및 디퍼드 딥링크 처리
|
||||
AppsFlyerLib.getInstance().subscribeForDeepLink { deepLinkResult ->
|
||||
when (deepLinkResult.status) {
|
||||
DeepLinkResult.Status.FOUND -> {
|
||||
val deepLink = deepLinkResult.deepLink
|
||||
SharedPreferenceManager.marketingLinkValue = deepLink?.getStringValue(
|
||||
"deep_link_value"
|
||||
) ?: ""
|
||||
|
||||
val marketingPid = deepLink?.getStringValue(
|
||||
"deep_link_sub1"
|
||||
)
|
||||
|
||||
if (marketingPid != null) {
|
||||
SharedPreferenceManager.marketingPid = marketingPid
|
||||
}
|
||||
|
||||
SharedPreferenceManager.marketingUtmSource = deepLink?.getStringValue(
|
||||
"deep_link_sub2"
|
||||
) ?: ""
|
||||
SharedPreferenceManager.marketingUtmMedium = deepLink?.getStringValue(
|
||||
"deep_link_sub3"
|
||||
) ?: ""
|
||||
SharedPreferenceManager.marketingUtmCampaign = deepLink?.getStringValue(
|
||||
"deep_link_sub4"
|
||||
) ?: ""
|
||||
SharedPreferenceManager.marketingLinkValueId = deepLink?.getStringValue(
|
||||
"deep_link_sub5"
|
||||
)?.toLongOrNull() ?: 0L
|
||||
}
|
||||
|
||||
DeepLinkResult.Status.NOT_FOUND -> Logger.d("딥링크를 찾을 수 없습니다.")
|
||||
DeepLinkResult.Status.ERROR -> Logger.d("딥링크 처리 중 오류 발생: ${deepLinkResult.error}")
|
||||
}
|
||||
}
|
||||
|
||||
startActivity(
|
||||
Intent(applicationContext, SplashActivity::class.java).apply {
|
||||
data = intent.data
|
||||
}
|
||||
)
|
||||
|
||||
Handler(Looper.getMainLooper()).postDelayed({
|
||||
finish()
|
||||
}, 1000)
|
||||
}
|
||||
}
|
|
@ -314,51 +314,66 @@ class MainActivity : BaseActivity<ActivityMainBinding>(ActivityMainBinding::infl
|
|||
}
|
||||
} catch (_: IllegalStateException) {
|
||||
}
|
||||
} else {
|
||||
val deepLinkValue = SharedPreferenceManager.marketingLinkValue
|
||||
val deepLinkValueId = SharedPreferenceManager.marketingLinkValueId
|
||||
}
|
||||
|
||||
if (deepLinkValue.isNotBlank() && deepLinkValueId > 0) {
|
||||
when (deepLinkValue) {
|
||||
"series" -> {
|
||||
startActivity(
|
||||
Intent(applicationContext, SeriesDetailActivity::class.java).apply {
|
||||
putExtra(Constants.EXTRA_SERIES_ID, deepLinkValueId)
|
||||
}
|
||||
)
|
||||
}
|
||||
executeOneLink()
|
||||
}
|
||||
|
||||
"content" -> {
|
||||
startActivity(
|
||||
Intent(
|
||||
applicationContext,
|
||||
AudioContentDetailActivity::class.java
|
||||
).apply {
|
||||
putExtra(Constants.EXTRA_AUDIO_CONTENT_ID, deepLinkValueId)
|
||||
}
|
||||
)
|
||||
}
|
||||
private fun executeOneLink() {
|
||||
val deepLinkValue = SharedPreferenceManager.marketingLinkValue
|
||||
val deepLinkValueId = SharedPreferenceManager.marketingLinkValueId
|
||||
|
||||
"channel" -> {
|
||||
startActivity(
|
||||
Intent(applicationContext, UserProfileActivity::class.java).apply {
|
||||
putExtra(Constants.EXTRA_USER_ID, deepLinkValueId)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
"live" -> {
|
||||
viewModel.clickTab(MainViewModel.CurrentTab.LIVE)
|
||||
|
||||
handler.postDelayed({
|
||||
liveFragment.enterLiveRoom(deepLinkValueId)
|
||||
}, 500)
|
||||
}
|
||||
|
||||
else -> {}
|
||||
if (deepLinkValue.isNotBlank() && deepLinkValueId > 0) {
|
||||
updatePidAndGaid()
|
||||
when (deepLinkValue) {
|
||||
"series" -> {
|
||||
startActivity(
|
||||
Intent(applicationContext, SeriesDetailActivity::class.java).apply {
|
||||
putExtra(Constants.EXTRA_SERIES_ID, deepLinkValueId)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
"content" -> {
|
||||
startActivity(
|
||||
Intent(
|
||||
applicationContext,
|
||||
AudioContentDetailActivity::class.java
|
||||
).apply {
|
||||
putExtra(Constants.EXTRA_AUDIO_CONTENT_ID, deepLinkValueId)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
"channel" -> {
|
||||
startActivity(
|
||||
Intent(applicationContext, UserProfileActivity::class.java).apply {
|
||||
putExtra(Constants.EXTRA_USER_ID, deepLinkValueId)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
"live" -> {
|
||||
viewModel.clickTab(MainViewModel.CurrentTab.LIVE)
|
||||
|
||||
handler.postDelayed({
|
||||
liveFragment.enterLiveRoom(deepLinkValueId)
|
||||
}, 500)
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
|
||||
clearDeferredDeepLink()
|
||||
}
|
||||
|
||||
private fun clearDeferredDeepLink() {
|
||||
SharedPreferenceManager.marketingUtmSource = ""
|
||||
SharedPreferenceManager.marketingUtmMedium = ""
|
||||
SharedPreferenceManager.marketingUtmCampaign = ""
|
||||
SharedPreferenceManager.marketingLinkValue = ""
|
||||
SharedPreferenceManager.marketingLinkValueId = 0
|
||||
}
|
||||
|
||||
private fun setupBottomTabLayout() {
|
||||
|
|
Loading…
Reference in New Issue