FBSDK Share not working in react-native app. On some android devices only

1.4k Views Asked by At

I am using react-native-fbsdk in my react-native application. I followed the official setup guide for the same. And managed to integrate it in the app.

I am using following standard code to share the link using ShareDialog

const shareLinkContent = {
                             contentType: 'link',
                             contentUrl: 'http://www.google.com',
                             quote: 'try this',
                         };

ShareDialog.canShow(shareLinkContent)
                .then(
                    (canShow) => {
                        if (canShow) {
                            return ShareDialog.show(shareLinkContent);
                        }
                    },
                )
                .then(
                    (result) => {
                        if (result.isCancelled) {
                            alert('Share cancelled');
                        } else {
                            alert(`Share success with postId: ${
                                result.postId }`);
                        }
                    },
                    (error) => {
                        alert(`Share fail with error: ${ error }`); // I get the error on this line.
                    },
                );

Above code works fine on iOS and some of the android devices. But on some android devices i get error as Share fail with error: Error: API_ERROR: API_ERROR

Not getting what is wrong for only subset of devices

Devices i faced problems are

Google Pixel gen 1, Some SAMSUNG devices, oppo.

Devices i managed to run without errors :

Xiaomi redme note 4, google nexus 5

Thanks in advance for the help

2

There are 2 best solutions below

0
On BEST ANSWER

Posting it late: I figured out what was the problem.

The facebook app need to be published to production on the facebook developer console. Hope it helps you all reading this.

0
On

I am also facing the same problem for my app. I am creating a react native based app that is using fbsdk. I followed the steps from React Native FBSDK. I get no error from android when I run it. The compilation is fine and the app is also running perfectly on mobile.

When I run react-native run-android I have no error and I can even see facebook loginButton. But when I click on the button, it doesn't bring me to the facebook login page most of the times. Specially in Samsung mobile series its not opening login page or sometimes i need to click multiple to the loginButton then it appears login page. In other mobiles its working fine.

I found this issue specifically in Android 8 and 9 versions of Samsung Galaxy (S6, S7, S8, S9, S9+) and Samsung Note 9 series. The issue is occurring random, means sometimes the login button is showing popup to login with facebook and sometimes not. Similarly sometimes share dialog is opening and sometimes not.

Even I tried in emulator of Samsung Galaxy (S6, S7, S8, S9, S9+) and Samsung Note 9 series, but its working fine in emulators. I cannot be able to debug the actual cause of such error. It is happening only in real device.

I have posted the same issued in React Native github repository as:

This and this

And from last 2 weeks waiting for response from fbsdk team but till now no one responded. Today I have posted the same issue on fb developers as a Bug check it here