Initialize Facebook Core SDK for iOS using Objective C?

1.4k Views Asked by At

I want to add the Facebook Events tracking to my app, but as it appears Facebook SDK documentation only provides the code in Swift language:

class AppDelegate: UIResponder, UIApplicationDelegate {    
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {          
    ApplicationDelegate.shared.application(
        application,
        didFinishLaunchingWithOptions: launchOptions
    )

    return true
}

As I read I should use FBSDKApplicationDelegate but I'm not sure how.

Thanks

2

There are 2 best solutions below

3
Abdulrahman Alhayek On

Initialize FBSDK

[FBSDKApplicationDelegate.sharedInstance application:application didFinishLaunchingWithOptions:launchOptions];
0
Wouter Seyen On

Add

#import <AuthenticationServices/AuthenticationServices.h>
#import <SafariServices/SafariServices.h>
#import <FBSDKCoreKit/FBSDKCoreKit-Swift.h>

to your import statements and

[[FBSDKApplicationDelegate sharedInstance] application:application
                       didFinishLaunchingWithOptions:launchOptions];

to didFinishLaunchingWithOptions

Thanks to the react-native-fbsdk-next package for providing this information (https://www.npmjs.com/package/react-native-fbsdk-next#32-ios)