Integration New Facebook Sdk by Swift

Integrating Facebook SDK with Xcode Swift project - AppDelegate errors?

You should import the SDK:

import FacebookCore

And I think the call should be:

SDKApplicationDelegate.shared

not

SDKApplicationDelegate.sharedInstance()

Hope this helps.

SwiftUI New App lifecycle how to connect the Facebook SDK

Add UIApplicationDelegateAdaptor to your SwiftUI App

import SwiftUI
import Firebase

@main
struct SplitApp: App {

@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate

var body: some Scene {
WindowGroup {
WelcomeView()
}
}


class AppDelegate: NSObject, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {

ApplicationDelegate.shared.application(
application,
didFinishLaunchingWithOptions: launchOptions
)

FirebaseApp.configure()


return true
}


func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {

ApplicationDelegate.shared.application(
app,
open: url,
sourceApplication: options[UIApplication.OpenURLOptionsKey.sourceApplication] as? String,
annotation: options[UIApplication.OpenURLOptionsKey.annotation]
)
}
}
}

How to Connect the App Delegate in Facebook SDK for iOS?

As I understand your iOS app is created and implemented using Objective C and so your not able to see AppDelegate.swift, If you want AppDelegate.swift then you have to create your iOS app using Swift.

AppDelegate.h/m files in Objective C are equivalent to AppDelegate.swift file in swift.

The Facebook SDK document you are referencing has given instruction with respect to swift iOS app.

You can refer below link for some Objective C code as well:
https://developers.facebook.com/docs/facebook-login/ios?sdk=fbsdk

There is no mention of Objective C in step 5. Connect Your App Delegate . However, I think you can skip this step and try from Step 6. Add Facebook Login to Your Code.(This step has both Swift and Objective-C code example.

iOS 14 get user consent with Facebook SDK

The documentation is at least misleading. You have to import FBSDKCoreKit.FBSDKSettings and the snippet is Settings.setAdvertiserTrackingEnabled(true). As you can see, it is not FBAdSettings but only Settings.

Converting Graph API from Swift 3 to Swift 5 for Facebook SDK

        func getFacebookProfileInfo() {
let requestMe = GraphRequest.init(graphPath: "me", parameters: ["fields" : "id,name,email,picture.type(large)"])
let connection = GraphRequestConnection()
connection.add(requestMe, completionHandler: { (connectn, userresult, error) in
if let dictData: [String : Any] = userresult as? [String : Any] {
DispatchQueue.main.async {
if let pictureData: [String : Any] = dictData["picture"] as? [String : Any] {
if let data : [String: Any] = pictureData["data"] as? [String: Any] {

print(data)
print(dictData["email"]!)

}
}
}
}
})
connection.start()
}


Related Topics



Leave a reply



Submit