<activity android:name=".DynamicLinkActivity">
<!-- 앱링크를 사용한 동적링크 처리 intent filter -->
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:scheme="http" />
<!-- 동적링크 도메인-->
<data
android:host="xfile6912.page.link"
android:scheme="https" />
</intent-filter>
<!-- deep link에 대한 intent filter -->
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:scheme="http" />
<!-- 딥링크 -->
<data
android:host="www.focusly.shop"
android:scheme="https" />
</intent-filter>
</activity>
fun dealDynamicLink(){
Firebase.dynamicLinks
.getDynamicLink(intent)//intent로부터 dynamic link 받아옴.
.addOnSuccessListener(this) { pendingDynamicLinkData ->
// Get deep link from result (may be null if no link is found)
var deepLink: Uri? = null
if (pendingDynamicLinkData != null) {
deepLink = pendingDynamicLinkData.link //deep link 추출
}
////////////// Handle deep link.///////////////////////////////////////////////////////////////////
if (deepLink != null) {
val type = deepLink.lastPathSegment//deep link로부터 정보 추출.
when(type){
TYPE_COUPON-> {//coupon 코드인 경우
val code=deepLink.getQueryParameter(CODE)
coupon_text.setText(code)
}
}
}
////////////// Handle deep link.///////////////////////////////////////////////////////////////////
}
.addOnFailureListener(this) { e ->
Log.w("DynamicLink", "getDynamicLink:onFailure", e)
}
}
//Handle deep link//안에 원하는 코드 삽입.