From bc2bb3dff6cb9a13023415a1a1c6e5a4e24b9a6c Mon Sep 17 00:00:00 2001 From: tmdgh1592 Date: Tue, 8 Feb 2022 14:32:24 +0900 Subject: [PATCH] Feature(invite link): "Create custom dynamic link for invitation" - Create custom invitation link with user ID query set Related to : #102 --- app/src/main/AndroidManifest.xml | 9 ++-- .../inviteLink/InviteLinkActivity.kt | 9 +++- .../lesson/progress/ClassProgressActivity.kt | 44 +++++++++---------- 3 files changed, 33 insertions(+), 29 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index fb7f855..a08547d 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -23,12 +23,15 @@ + + android:host="pingpongservice.page.link" + android:path="/invite" + android:scheme="https" /> diff --git a/app/src/main/java/com/dnd/sixth/lmsservice/presentation/inviteLink/InviteLinkActivity.kt b/app/src/main/java/com/dnd/sixth/lmsservice/presentation/inviteLink/InviteLinkActivity.kt index 4fd518e..4ad5582 100644 --- a/app/src/main/java/com/dnd/sixth/lmsservice/presentation/inviteLink/InviteLinkActivity.kt +++ b/app/src/main/java/com/dnd/sixth/lmsservice/presentation/inviteLink/InviteLinkActivity.kt @@ -37,10 +37,15 @@ class InviteLinkActivity : BaseActivity - showToast(shortDynamicLink.shortLink.toString()) - shortDynamicLink.shortLink?.let { sendInviteLink(it) } - }.addOnFailureListener { - if (BuildConfig.DEBUG) { - it.printStackTrace() - } - showToast("초대하기 기능에 실패했습니다.") - } + + // (Manifest에 설정한 scheme, host, path와 동일해야 함.) + val invitationLink = "https://pingpongservice.page.link/invite?uid=$userId" // 생성할 다이나믹 링크 + + val dynamicLink = + FirebaseDynamicLinks.getInstance().createDynamicLink() + .setLink(Uri.parse(invitationLink)) + .setDomainUriPrefix("https://pingpongservice.page.link") // 파이어베이스 다이나믹 링크란에 설정한 Prefix 입력 + .setAndroidParameters( + AndroidParameters.Builder().build() + ) + .buildShortDynamicLink() + + dynamicLink.addOnSuccessListener { task -> + val inviteLink = task.shortLink!! + sendInviteLink(inviteLink) + } + } @@ -115,7 +111,7 @@ class ClassProgressActivity : BaseActivity