I've cleaned out my project to iron out all the errors. App seems to launch and the login page seems to work, but when I tried logging in to Facebook, this is what happens:
TCP_CONNECTION_EVENT_TLS_HANDSHAKE_COMPLETE in response to state ready and error (null)
2016-09-15 12:36:50.254067 2[3083:89230] [] tcp_connection_event_notify 12 event: TCP_CONNECTION_EVENT_TLS_HANDSHAKE_COMPLETE, reason: nw_connection event, should deliver: true
2016-09-15 12:36:50.254511 2[3083:89230] [] tcp_connection_get_statistics DNS: 3ms/7ms since start, TCP: 61ms/76ms since start, TLS: 99ms/172ms since start
2016-09-15 12:36:50.492341 2[3083:89140] [] tcp_connection_cancel 12
2016-09-15 12:36:50.493012 2[3083:88773] [] nw_socket_handle_socket_event Event mask: 0x4
2016-09-15 12:36:50.493506 2[3083:88773] [] nw_socket_handle_socket_event Socket received WRITE_CLOSE event
2016-09-15 12:36:50.494087 2[3083:88773] [] nw_endpoint_handler_cancel [12 graph.facebook.com:443 ready resolver (satisfied)]
2016-09-15 12:36:50.494691 2[3083:88773] [] nw_endpoint_handler_cancel [12.1 31.13.78.13:443 ready socket-flow (satisfied)]
2016-09-15 12:36:50.495482 2[3083:88773] [] __nw_socket_service_writes_block_invoke sendmsg(fd 15, 31 bytes): socket has been closed
2016-09-15 12:36:50.495878 2[3083:88773] [] nw_endpoint_flow_protocol_error [12.1 31.13.78.13:443 cancelled socket-flow (null)] Socket protocol sent error: [32] Broken pipe
2016-09-15 12:36:50.496536 2[3083:88773] [] nw_endpoint_flow_protocol_disconnected [12.1 31.13.78.13:443 cancelled socket-flow (null)] Output protocol disconnected
2016-09-15 12:36:50.496888 2[3083:88773] [] nw_resolver_cancel_on_queue 0x6000003042f0
2016-09-15 12:36:50.497285 2[3083:88773] [] -[NWConcrete_tcp_connection dealloc] 12
This is just a snippet of the log file of the output when I tried logging in.
By the way, my code is set up as such for the loginviewcontroller
import UIKit
import FBSDKLoginKit
import Firebase
import FirebaseAuth
class FacebookLoginViewController: UIViewController, FBSDKLoginButtonDelegate{
var loginButton: FBSDKLoginButton = FBSDKLoginButton()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
self.loginButton.center = self.view.center
self.loginButton.readPermissions = ["public_profile", "email", "user_friends"]
self.view!.addSubview(loginButton)
self.loginButton.delegate = self
FIRAuth.auth()?.addAuthStateDidChangeListener { auth, user in
if let user = user {
// User is signed in.
self.performSegueWithIdentifier("loggedIn", sender: self)
}
}
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func loginButton(loginButton: FBSDKLoginButton!, didCompleteWithResult result: FBSDKLoginManagerLoginResult!, error: NSError!) {
print("user logged in")
if(error != nil)
{
}
else if(result.isCancelled){
}
else{
// Exchange facebook credential for a firebase credential
let credential = FIRFacebookAuthProvider.credentialWithAccessToken(FBSDKAccessToken.currentAccessToken().tokenString)
// Login to firebase
FIRAuth.auth()?.signInWithCredential(credential) { (user, error) in
self.performSegueWithIdentifier("loggedIn", sender: self)
print("user logged in to firebase")
}
}
}
func loginButtonDidLogOut(loginButton: FBSDKLoginButton!) {
print("user logged out")
}
}
here's the didFinishLaunchingWithOptions
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
FIRApp.configure()
// Override point for customization after application launch.
let navAppearance = UINavigationBar.appearance()
let tabAppearance = UITabBar.appearance()
let backImage = UIImage(named: "back")
navAppearance.backIndicatorImage = backImage
navAppearance.backIndicatorTransitionMaskImage = backImage
let lightBlackColour = UIColor(red: 50/255.0, green: 50/255.0, blue: 54/255.0, alpha: 1.0)
let lightYellowColour = UIColor(red: 255/255.0, green: 250/255.0, blue: 36/255.0, alpha: 1.0)
navAppearance.tintColor = lightYellowColour
navAppearance.barTintColor = lightBlackColour // Set the bar tint colour
navAppearance.titleTextAttributes = [NSForegroundColorAttributeName: lightYellowColour]
tabAppearance.barTintColor = lightBlackColour
tabAppearance.tintColor = lightYellowColour
let barButtonAppearance = UIBarButtonItem.appearance()
barButtonAppearance.setBackButtonTitlePositionAdjustment(UIOffsetMake(0, -60), forBarMetrics: .Default)
barButtonAppearance.setBackButtonTitlePositionAdjustment(UIOffsetMake(0, -60), forBarMetrics: .Compact)
UIApplication.sharedApplication().statusBarStyle = .LightContent
FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
return true
}
See Question&Answers more detail:
os