I am implementing Facebook login for my iOS application in Xcode 8.1, with Swift3. The operation is simply done with the following function:
[loginManager logInWithReadPermissions:@[@"email"]
fromViewController:self
handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
// my callback logic
}];
(I got this code snippet from the Facebook docs . I am not on my work computer right now; because of that, it is obj-c)
I also implemented everything perfectly, regarding AppDelegate
like methods of the Facebook login SDK, Info.plist
key-values etc.
When the user has the Facebook app installed, everything works fine.
However, when the user has no Facebook app installed, the callback of the former function is never invoked. SafaroViewController
shows up, the user logs in and either grants the permissions or rejects the request. And suddenly, SafariViewController
disappears and my callback does not get called ( AppDelegate
like methods of the Facebook login SDK get called).
What might be the problem?
Assign FBSDKLoginButton
as the class of your button instead of UIButton
and in your outlet too. Then set the button delegate
and permission
in viewDidLoad
.
@IBOutlet weak var faceBookLoginButton: FBSDKLoginButton!
// MARK: - View life cycle methods
override func viewDidLoad() {
super.viewDidLoad()
// Facebook Permissions
faceBookLoginButton.readPermissions = ["email"]
faceBookLoginButton.delegate = self
}
Thanks:)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.