Skip to content Skip to sidebar Skip to footer

Firebase Dynamic Link With Parameters

I am new to the community and I have joined because of the need to highlight a problem that I have not been able to solve. Thank you in advance for any answer you can give me to he

Solution 1:

Joe you need to pass the parameter you want to fetch as a query parameter.

Like this:
"https://palsuper.com?lista_compartida=" + Lid;
                        or
"https://palsuper.com/lista_compartida?lista_compartida=" + Lid;

And then you can fetch it simply using this firebase provided method:

UrideepLink=null;
                    if (pendingDynamicLinkData != null) {
                        deepLink = pendingDynamicLinkData.getLink();
                        Stringlista_compartida= deepLink.getQueryParameter("lista_compartida");

}

Hope this answer helps.

Solution 2:

Go to firbase console dynamic link section and then create a dynamic link such as https://xyz.page.link and then use below code to generate and share dynamic link

fungenerateContentLink(): Uri? {
    val baseUrl = Uri.parse(BASE_URL)
    val domain = "https://xyz.page.link"val link = FirebaseDynamicLinks.getInstance()
        .createDynamicLink()
        .setLink(baseUrl)
        .setDomainUriPrefix(domain)
        .setAndroidParameters(AndroidParameters.Builder("com.xyz").build())
        .buildDynamicLink()
    return link.uri
}

privatefunonShareClicked() {
    try {
        val link = generateContentLink()
        Log.e("DynamicLnk", "onShareClicked: " + link.toString())
        val subject = " Welcome to QuickPe"val msg =
            "Hi,\nInviting you to join xyz\n an interesting app which provides you\n" +
                    "incredible offers on Recharge, Shopping & many more.\n\n" +
                    "Use my referrer code :\n\n " + session()?.getInviteCode().toString() +
                    "\n\nDownload app from link : \n"val intent = Intent(Intent.ACTION_SEND)
        intent.type = "text/plain"
        intent.putExtra(Intent.EXTRA_SUBJECT, subject)
        intent.putExtra(Intent.EXTRA_TEXT,
            msg + "\n" + link + "/" + session()?.getInviteCode().toString())
        if (intent.resolveActivity(packageManager) != null) {
            startActivity(intent)
        }
    } catch (e: Exception) {
        e.printStackTrace()
    }
}

Now to receive code as below code in AndroidManifest.xml

<activityandroid:name=".xyzActivity"><intent-filter><actionandroid:name="android.intent.action.VIEW"/><categoryandroid:name="android.intent.category.DEFAULT"/><categoryandroid:name="android.intent.category.BROWSABLE"/><dataandroid:host="https://xyz.page.link"android:scheme="https"/></intent-filter></activity>

and in activity where you want to receive code

FirebaseDynamicLinks.getInstance()
        .getDynamicLink(intent)
        .addOnSuccessListener(this) { pendingDynamicLinkData ->
            // Get deep link from result (may be null if no link is found)vardeepLink: Uri? = nullif (pendingDynamicLinkData != null) {
                deepLink = pendingDynamicLinkData.link
            }
            if (deepLink != null) { //Intent.ACTION_VIEW.equals(appLinkAction) &&
                val code = deepLink.lastPathSegment
                edtReferralCode.setText(code)
            }

            // Handle the deep link. For example, open the linked// content, or apply promotional credit to the user's// account.// ...// ...
        }
        .addOnFailureListener(this) { e -> Log.w("=================>", "getDynamicLink:onFailure", e) }

Post a Comment for "Firebase Dynamic Link With Parameters"