thebergamo / react-native-fbsdk-next

MIT License
633 stars 165 forks source link

Facebook SDK not initialized error when using react-native-fbsdk-next with Expo #517

Closed ZiadEmadZaki closed 2 weeks ago

ZiadEmadZaki commented 2 weeks ago

Description: When integrating react-native-fbsdk-next with an Expo project, I consistently encounter the error message stating "Facebook SDK not initialized". This issue seems to persist despite following standard installation procedures for Expo projects. i Followed the steps required in the documentation

here is the code from my project image

Additional Context: we are not managing out native code in the project. but aftetr running 'npx expo run:android' and checking the generated files i can see that there are some lines missing from the AndroidManifest.xml file and the strings.xml files. when adding them the build is successful and the error is gone.

 <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/>
   <meta-data android:name="com.facebook.sdk.ClientToken" android:value="@string/facebook_client_token"/>
<string name="facebook_app_id">1234</string>
<string name="facebook_client_token">56789</string>

Steps to Reproduce:

Expected Behavior: The integration of react-native-fbsdk-next with Expo should seamlessly initialize the Facebook SDK without requiring manual intervention.

Actual Behavior: The Facebook SDK initialization fails, resulting in the "Facebook SDK not initialized" error message.

2024-04-15_20-57

Environment:

react-native-fbsdk-next version: ^12.1.4 Expo SDK version: 49 Platform: (iOS/Android): Android

Am i doing somethig wrong here ?

Flano-123 commented 2 weeks ago

image this line maybe should be: fb+your fb app id

ZiadEmadZaki commented 2 weeks ago

@Flano-123 Yes you are correct. but the issue persists regardless of the value of the scheme. i just tested again to be sure

uncledent commented 2 weeks ago

Down grade to 12.2.0 fixed it for me

ZiadEmadZaki commented 2 weeks ago

@uncledent i was already using version 12.1.4. and i just tested again with 12.2.0 and the same issue happens. could share some more details about your setup? like expo version and if you are implementing it the same way as i do.

uncledent commented 2 weeks ago

"expo": "^50.0.15"

Don't forget to put authToken into appjson config.

[ "react-native-fbsdk-next", { "appID": "", "clientToken": "", "displayName": "", "scheme": "", "advertiserIDCollectionEnabled": false, "autoLogAppEventsEnabled": false, "isAutoInitEnabled": true, "iosUserTrackingPermission": "This identifier will be used to deliver personalized content to you." } ]

  Also remove native projects and do the prebuild again after downgrading.