Monday 26 July 2021

Facebook share api for android opens web-based dialog instead of native app

I implement facebook share in my android app and as I read the docs it says :

"The Share dialog switches to the native Facebook for Android app, then returns control to your app after a post is published. Depending on the SDK you're using, people may need tap the back arrow icon to return to your app. If the Facebook app is not installed, the Share dialog automatically falls back to the web-based dialog."

I have this facebook share fucntion in MainActivity:

    fun facebookShare() {
        try {
            val content = ShareLinkContent.Builder()
                .setContentUrl(Uri.parse("https://play.google.com/store/apps/details?id=Avedot"))
                .setQuote(getString(R.string.facebookText))
                .build()
            val shareDialog = ShareDialog(this)
            if (shareDialog.canShow(content)) {
                shareDialog.show(content)
            }
        } catch (ex: ActivityNotFoundException) {
            Toast.makeText(this, "Facebook have not been installed.", Toast.LENGTH_SHORT).show()
        }
    }

and when I call the function it opens a web-based dialog instead of the facebook app (which is installed).. I tried reinstalling but still it does not work.. any suggestions why the share dialog opens as a web-based dialog and not in the native facebook app?

this is the web-based dialog it opens: enter image description here



from Facebook share api for android opens web-based dialog instead of native app

No comments:

Post a Comment