DEV Community

How to add FB SDK in react-native project

Aneeqa Khan on February 23, 2022

Hi fellow coders! Recently we needed to show our react native app ads on different platforms like Facebook or Instagram so for that you must have F...
Collapse
 
frankfuu profile image
Frank Fu

I also want to add that if you got the error. "use of undeclared identifier 'FBSDKApplicationDelegate" you might want to visit this github issue

github.com/facebookarchive/react-n...

Collapse
 
mohdumer profile image
Muhammad Umer

You only just need to declare
this import..

import

above the...

ifdef FB_SONARKIT_ENABLED in AppDelegate.m file

Now you are able to archive easily..🤩🤩🤩

Collapse
 
neha_gupta_82717add4ba5d4 profile image
Neha Gupta

Hi great article, I am new with native so just wanted to understand can we directly add the dependencies in build.gradle file as you mentioned in your article?

Collapse
 
aneeqakhan profile image
Aneeqa Khan

Yes

Collapse
 
qasimgit profile image
MUHAMMAD QASIM QADRI • Edited

Hey @aneeqakhan, thanks for writing this beautiful article,
just wanted to ask there are some steps which include swift code, I am not seeing these steps in your article, can you please add those steps too, very confused in how to add these swift code lines in react native, you can check those steps in Getting started Guide.
Thanks

Image description

Collapse
 
aneeqakhan profile image
Aneeqa Khan

Yes, just like mentioned in your screenshot that step 3 and 4 have swift code in official docs of FB SDK, so thats why fbsdk-next guide provided that code in Objective-C under the Note text.

Collapse
 
uziel302 profile image
Asaf M • Edited

I followed the instructions and was getting error:
No visible @interface for 'FBSDKApplicationDelegate' declares the selector 'initializeSDK'
I had react-native-fbsdk-next previously installed, so I had to delete its reference from package.json and package-lock.json and rerun:
npm install --save react-native-fbsdk-next
pod install
to get the latest versions, where initializeSDK is supported

Another caveat, I was sending custom events, so I couldn't see them on default events manager view, had to switch to "all events" to see them.

Collapse
 
sufian_s1999 profile image
Sufian Ahmad • Edited

Hello.
Did you face any UI problems in the SDK?
For instace, during the integration process, buttons like Next, Continue, and Cancel disappear.
This issue is in the latest version of SDK.
When I delete the FB app then I enter credentials in the webview and there the buttons won't hide but when it opens FB app to login, then this issue come.

Image1

Image2

Collapse
 
anderson_guerra_8285d88c8 profile image
Anderson Guerra

Did you solve this problem?

Collapse
 
sufian_s1999 profile image
Sufian Ahmad

No. Didn't find any solution.

Collapse
 
bishalsaha profile image
Bishal Saha

Replace

#import <FBSDKCoreKit/FBSDKCoreKit.h>

to

#import <FBSDKCoreKit/FBSDKCoreKit-Swift.h>

Collapse
 
dhannyphantom profile image
Olojo Daniel Oluwaseun

Does this package work with Expo?

Collapse
 
aneeqakhan profile image
Aneeqa Khan

I guess no, there is no installation guide provided for expo

Collapse
 
shuzo-nomad profile image
Shuzo Otani
Collapse
 
shuzo-nomad profile image
Shuzo Otani
Collapse
 
yprince19 profile image
yprince19 • Edited

Hi @aneeqakhan thanks for this awesome blog.
I want to add multiple fb-pixel accounts for tracking. How to do this?