0

I have to add an extra parameter as "meetingToken" in firebase deeplink .

But On adding an extra parameter "meetingtoken" as queryparameter im not recieving the value and getting error in joinmeeting(it) : No value passed for parameter meetingToken.

While the same works fine on passing a single parameter, What changes do i need to recieve both the parameters value.

Currently its giving me error at:

 deepLink?.getQueryParameter("meetingCode")?.let { joinMeeting(it) }

No value passed for parameter 'meetingToken'

Link = https://example.in/?meetingCode=myuser?meetingToken=rtgdhh.tywufgsioqpp

private fun handleDynamicLink() {
    Firebase.dynamicLinks
        .getDynamicLink(intent)
        .addOnSuccessListener { pendingDynamicLinkData ->
            val deepLink: Uri?
            if (pendingDynamicLinkData != null) {
                deepLink = pendingDynamicLinkData.link

on android debugging its generating the following firebase Link = https://example.in/?meetingCode=userroom?meetingToken%3DeyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1Ni

                deepLink?.getQueryParameter("meetingToken")
                deepLink?.getQueryParameter("meetingCode")?.let { joinMeeting(it) }


            }
        }
        .addOnFailureListener { _ ->
            toast(getString(R.string.main_error_fetch_dynamic_link))
        }
}



 private fun joinMeeting (meetingCode:String, meetingToken:String) {
    MeetingUtils.startMeeting(
        this, meetingCode,
    meetingToken)


}

meeting Utils.kt file to start meeting

object MeetingUtils {


fun startMeeting(context: Context,  meetingCode: String, meetingToken: String)

app deep link url string

<string name="app_deep_link_url">https://example.in/?meetingCode=%1$s?meetingToken=%2$s</string>

this is the share code

    private fun onShareMeetingCodeClick() {
    tilCodeCreateMeeting.setEndIconOnClickListener {

            binding.tilCodeCreateMeeting.error = null
            toast(getString(R.string.main_creating_dynamic_link))

            Firebase.dynamicLinks.shortLinkAsync {
                link = Uri.parse(getString(R.string.app_deep_link_url, getCreateMeetingCode(), getCreateMeetingToken() ))
                domainUriPrefix = getString(R.string.app_dynamic_link_url_prefix)
                androidParameters {}
                navigationInfoParameters {
                    forcedRedirectEnabled = true // Directly open the link in the app
                }
            }.addOnSuccessListener { result ->
                val shortDynamicLink = result.shortLink.toString()
                startShareTextIntent(
                    getString(R.string.main_share_meeting_code_title),
                    getString(R.string.main_share_meeting_code_desc, shortDynamicLink)
                )
            }.addOnFailureListener {
                toast(getString(R.string.main_error_create_dynamic_link))
            }

Can Someone guide me how to recieve value of getQueryparameter for more than 1 parameter. Thanks in Advance

Chris John
  • 13
  • 8

1 Answers1

0

You should use & instead of ? on appending the second parameter on your deep link. Also, the deep link configured should be URL-encoded since multiple parameters are configured in the deep link. Your sample deep link should look like this.

link=https%3A%2F%2Fexample.in%2F%3FmeetingCode%3Dmyuser%26meetingToken%3Drtgdhh.tywufgsioqpp

By URL-encoding the deep link, FDL will able to distinguish which parameters belongs to the deep link.

Uri.parse(getString(R.string.app_deep_link_url, getCreateMeetingCode(), getCreateMeetingToken())) 

I'm not sure on what you're trying to achieve passing multiple parameters on getString for the deep link value.

Won't it make sense to create a StringBuilder or append it manually?

val deepLink = getString(R.string.app_deep_link_url)+ "%2F%3FmeetingCode%3D$meetingCode%26meetingToken%3D$meetingToken";
link = Uri.parse(deepLink);

where "app_deep_link_url" in strings.xml is

<string name="app_deep_link_url">https%3A%2F%2Fexample.in</string>
Omatt
  • 8,564
  • 2
  • 42
  • 144
  • I tried this but it shows syntax error. ? (`https://modimeet.in/?meetingCode=%1$s&meetingToken=%2$s`?) Also as im new to kotlin i have doubt here: ? (` .let { joinMeeting(it) }`?) because its showing error on (it) No value pass for meetingToken – Chris John Oct 31 '20 at 15:02
  • Is there a way we can pair them in 1 ? (`deepLink?.getQueryParameter("meetingCode", "meetingToken")`?) So it will able to distinguish it .let { joinMeeting(it) – Chris John Oct 31 '20 at 15:14
  • I'm not sure on what you're trying to achieve passing multiple parameters on getString for the deep link value. `Uri.parse(getString(R.string.app_deep_link_url, getCreateMeetingCode(), getCreateMeetingToken()))` Won't it make sense to create a [StringBuilder](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.text/-string-builder/) or append it manually? – Omatt Oct 31 '20 at 18:00
  • You can append it manually with ```kotlin val deepLink = getString(R.string.app_deep_link_url)+ "%2F%3FmeetingCode%3D$meetingCode%26meetingToken%3D$meetingToken"; link = Uri.parse(deepLink); ``` where "app_deep_link_url" is `https%3A%2F%2Fexample.in` – Omatt Oct 31 '20 at 18:11
  • Actually its a meeting app we need roomcode & roomtoken to enter. Whenever anyone create a new meeting. the following code will generate a long link for room & token for the meeting: ? (`link = Uri.parse(getString(R.string.app_deep_link_url, getCreateMeetingCode(), getCreateMeetingToken() ))`?) and later the firebase short link we can send for invite to other user: domain.page.link/arsshshsj When anyone clicks on the above link then this firebase code will be executed: ? (`deepLink?.getQueryParameter("meetingCode")?.let { joinMeeting(it) }`?) So that we can start >> – Chris John Oct 31 '20 at 18:47
  • So that we can start a function to execute meeting: ? (`private fun joinMeeting (meetingCode:String, meetingToken:String) { MeetingUtils.startMeeting( this, meetingCode, meetingToken) }`?) The issue is previously its working fine with 1 parameter meetingcode. after adding the meetingtoken parameter its giving issue at ?.let { joinMeeting(it) – Chris John Oct 31 '20 at 18:53