Hi everyone I'm using DTSocialMediaLogin for the social media logins (Facebook, Google, Twitter) all of them works except Facebook. When ı try to Facebook login, it's not logged because "email" is not getting.
Here is the result of the coming data
There is no email on coming data as you can see on the image.
Here is the permission section:
func login(from viewController: UIViewController, done: @escaping(_ status: Bool, _ message: String, _ user: DTFacebookUser?) -> Void) {
let login = FBSDKLoginKit.LoginManager()
login.defaultAudience = .everyone
if scopes.count == 0 {
scopes = ["public_profile", "email"]
}
login.logIn(permissions: scopes, from: viewController) { (result, error) in
DispatchQueue.main.async {
if error != nil {
done(false, error!.localizedDescription, nil)
}
else if let result = result {
if result.isCancelled && result.declinedPermissions.count > 0 {
done(false, "facebook_cancel_declined", nil)
}
else {
//let userID = result.token?.userID
self.graph(str: "/me?fields=email,name", done: done)
}
}
}
}
}
Here is the login action:
@objc func actionFacebook() {
self.socialLogin.login(with: .Facebook, from: self) { (error, user) in
// user.name, user.email, user.id, user.profileImageURL
if user == nil {
return
}
var text = "FACEBOOK LOGIN\n"
text = "\(text)\nFull Name: \(user!.name)"
text = "\(text)\nEmail: \(user!.email)"
text = "\(text)\nUser ID: \(user!.id)"
text = "\(text)\nImage: \(user!.profileImageURL)"
print(text)
if user!.email == "" {
return
}
if user!.name == "" {
return
}
if self.passSignType == "Login"
{
ServiceManager.shared.Authenticate(Phone: "", MobilePin: "", Email: user!.email, Password: "", ProviderName: "Facebook", ProviderId: user!.id, ProviderToken: "", Name: user!.name, Username: user!.name, ActionType: "Login", callbackSuccess: { (response) in
HUD.flash(.label("hudAccountLogin".localized()), delay: 1.0) { _ in
}
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
self.dismiss(animated: true) {
}
NotificationCenter.default.post(name: Notification.Name(rawValue: "UserLogged"), object: nil)
}
}) { (response) in
HUD.flash(.label("hudFailed".localized()), delay: 1.0) { _ in
}
}
}
}
I cant solve the problem Email is not coming on Facebook...