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
How to Load a Url Link That Is Inside a Web View and Keep It in That Web View in Swift
How to Bring Application to Foreground in iOS
Navigationbar Bar, Tint, and Title Text Color in iOS 8
Atos Cannot Get Symbols from Dsym of Archived Application
After Switching to Xcode 7, App Size Grew from 9 Mb to 60 Mb, Is There a Fix
Error Itms-90164/90046: Invalid Code Signing Entitlements
Referring to Weak Self Inside a Nested Block
How to Access Files in Icloud Drive from Within My iOS App
Use Table View Disclosure Indicator Style for Uibutton iOS
Why Is Our Monotouch App Breaking in the Garbage Collector? It Is Not Out of Memory
Upload Files to Dropbox from iOS App with Swift
Rotating a View in Layoutsubviews
How to Implement a Swiping/Sliding Animation Between Views
Swift - How to Dismiss All of View Controllers to Go Back to Root
Swift: How to Refresh Uicollectionview Layout After Rotation of the Device
Share Extension to Open Containing App
iOS Different Font Sizes Within Single Size Class for Different Devices