Get a larger facebook image via firebase login

I use firebase to log in user via facebook. All this works great, and I can get an FB user profile picture, although itโ€™s small. Can someone tell me how to get more code that I use:

override func viewDidLoad() { let loginButton = FBSDKLoginButton() loginButton.readPermissions = ["public_profile", "email"] loginButton.delegate = self self.view.addSubview(loginButton) } func loginButton(loginButton: FBSDKLoginButton!, didCompleteWithResult result: FBSDKLoginManagerLoginResult!, error: NSError?) { let credential = FIRFacebookAuthProvider.credentialWithAccessToken(FBSDKAccessToken.currentAccessToken().tokenString) FIRAuth.auth()?.signInWithCredential(credential) { (user, error) in if let user = FIRAuth.auth()?.currentUser { for profile in user.providerData { let photoUrl = profile.photoURL?.absoluteString //SMALL IMAGE } } } } 

(This is fast)

+1
swift facebook-graph-api firebase firebase-authentication facebook-login
source share
2 answers

According to the documentation in the Picture profile, you must specify the size by adding width and height to the URL:

 let photoUrl = profile.photoURL?.absoluteString + "?width=\(width)&height=\(height)" 

or specifying type:

 let photoUrl = profile.photoURL?.absoluteString + "?type=large" 
-2
source share

Once the FB user is authenticated, create an FBSDKGraphRequest using the FBSDKGraphRequestConnection to get the FBid users, using which you can get the user profile picture by inserting the id here:

https://graph.facebook.com/ / picture? type = large & return_ssl_resources = 1

instead of type=large you can also use ?width=<width>&height=<height>

too

+1
source share

All Articles