After integrating with facebook when I tap on continue with FaceBook button on simulator, it popups this window on simulator..and when I tap on back to home it redirects me to login window and allows me to scroll in facebook insted of redirecting back to my app, and I am not getting any user data with it.
Here is steps that I have done
- Pod installation: pod 'FBSDKLoginKit'
- Added Bundle ID in quickstart guide in developer.facebook
- Enable Single Sign option is selected to NO
- Added the following code as it is in info.plist
Added the following code in AppDelegate
According to Facebook document we have to import FacebookCore in AppDelegate when we Import it we get warning No such module 'FacebookCore'
import FBSDKCoreKit
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
ApplicationDelegate.shared.application(
application,
didFinishLaunchingWithOptions: launchOptions
)
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]
)
}
Added the following code in SceneDelegate
According to Facebook document we have to import FacebookCore in SceneDelegate when we Import it we get warning No such module 'FacebookCore'
import FBSDKCoreKit
func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
guard let url = URLContexts.first?.url else {
return
}
ApplicationDelegate.shared.application(
UIApplication.shared,
open: url,
sourceApplication: nil,
annotation: [UIApplication.OpenURLOptionsKey.annotation]
)
}
Added the following code in ViewController
According to Facebook document we have to import FacebookLogin in ViewController when we Import it we get warning No such module 'FacebookLogin'
import FBSDKLoginKit
class ViewController: UIViewController, LoginButtonDelegate
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
if let token = AccessToken.current,
!token.isExpired {
let token = token.tokenString
let request = FBSDKLoginKit.GraphRequest(graphPath: "me", parameters: ["fields": "email,name"], tokenString: token, version: nil, httpMethod: .get)
request.start { connecton, result, error in
print("\(result)")
}
} else{
let loginButton = FBLoginButton()
loginButton.center = view.center
loginButton.delegate = self
loginButton.permissions = ["public_profile", "email"]
view.addSubview(loginButton)
}
}
func loginButton(_ loginButton: FBLoginButton, didCompleteWith result: LoginManagerLoginResult?, error: Error?) {
let token = result?.token?.tokenString
let request = FBSDKLoginKit.GraphRequest(graphPath: "me", parameters: ["fields": "email,name"], tokenString: token, version: nil, httpMethod: .get)
request.start { connecton, result, error in
print("\(result)")
}
}
I have tried step 2 from this but I am getting this error while setting development environment.