4

I'm experimenting with Firebase Dynamic Links and so far all of it works, but not the part with the social parameters. Whenever I share my link it only has the actual clickable link and a message sent through the intent but there's no social title, image or description. I am currently adding my image through drawable folder and the image is less than 300kb and at least 300x200. For example when I share my link through Viber it only says Hey, check out my link: <the link here>

Sharing on WhatsApp it does work, the image is shown along with the social title and description, but Viber and Instagram do not show the social metadata. Also, the link on Instagram is not clickable. How do I debug this?

Here's my code:

    private fun createShareUri(deepId: String): Uri {
        val builder = Uri.Builder()
        builder.scheme(getString(R.string.config_scheme)) // "http"
                .authority(getString(R.string.config_host)) // "deeplink.xyz"
                .appendPath(getString(R.string.config_path_deep)) // "deep"
                .appendQueryParameter(QUERY_PARAM_DEEP, deepId)
        return builder.build()
    }

private fun createDynamicUri(myUri: Uri): Uri {
        val imgUri = getUriToResource(this, R.drawable.mypic)
        val dynamicLink = FirebaseDynamicLinks.getInstance().createDynamicLink()
                .setLink(myUri)
                .setDynamicLinkDomain(DYNAMIC_LINK_DOMAIN)
                .setAndroidParameters(DynamicLink.AndroidParameters.Builder()
                        .build())
                .setSocialMetaTagParameters(DynamicLink.SocialMetaTagParameters.Builder()
                        .setTitle("Social Meta Title")
                        .setDescription("Social Meta Description")
                        .setImageUrl(imgUri)
                        .build())
                .buildDynamicLink()
        return dynamicLink.uri
    }

private fun shortenLink(linkUri: Uri) {
        FirebaseDynamicLinks.getInstance().createDynamicLink()
                .setLongLink(linkUri)
                .buildShortDynamicLink()
                .addOnCompleteListener { task ->
                    if (task.isSuccessful) {
                        val shortLink = task.result.shortLink
                        val msg = "Hey, check out my link: $shortLink"
                        val sendIntent = Intent()
                        sendIntent.action = Intent.ACTION_SEND
                        sendIntent.putExtra(Intent.EXTRA_TEXT, msg)
                        sendIntent.type = "text/plain"
                        startActivity(Intent.createChooser(sendIntent, "Share via"))
                    } else {
                        Timber.e(task.exception)
                    }
                }
    }

private fun share(id: String) {
        val myUri = createShareUri(id)
        Timber.d("Shared Link: $myUri")

        val dynamicLinkUri = createDynamicUri(myUri)
        Timber.d("Dynamic Link: $dynamicLinkUri")

        shortenLink(dynamicLinkUri)
    }

Edit: here's my dynamic link: https://deeplinktest.page.link?sd=Social%20Meta%20Description&si=android.resource%3A%2F%2Fcom.example.deeplinktest.deeplinks%2Fdrawable%2Fmypic&st=Social%20Meta%20Title&apn=com.example.deeplinktest.deeplinks&link=https%3A%2F%2Fdeeplink.xyz%2Fdeep%3FdeepId%3D2

jlively
  • 735
  • 2
  • 9
  • 29

0 Answers0