[英]iOS/Swift/FBSDKLoginKit: Login using FBSDKLoginManager().logInWithReadPermissions gets failed by getting result.isCancelled to true
I am working on App in which I have added FBSDKLoginKit to allow user login using Facebook. 我正在开发其中添加了FBSDKLoginKit的应用程序,以允许用户使用Facebook登录。 After entering facebook user id and password, I see below page.
输入Facebook用户名和密码后,我将看到以下页面。
Now, I press ok button, I am seeing blank page. 现在,我按确定按钮,我看到空白页。
As expected, I should not see blank page. 不出所料,我应该看不到空白页。 So I press Done button at upper left corner, program call function handleImplicitCancelOfLogIn from SDK and I see login's not successful and the its routed to app's login home page.
因此,我按了左上角的“完成”按钮,从SDK调用了程序调用函数handleImplicitCancelOfLogIn,我看到登录不成功并将其路由到应用程序的登录主页。
I don't see any error while debugging, but when I press Done button I see flag result.isCancelled is set to true (because done button tap calls function handleImplicitCancelOfLogIn) 我在调试时没有看到任何错误,但是当我按“完成”按钮时,我看到标志result.isCancelled设置为true(因为完成按钮点击会调用handleImplicitCancelOfLogIn函数)
FBSDKLoginManager().logInWithReadPermissions(["public_profile"], fromViewController: hostViewController) { (result, error) in
if error != nil || result.isCancelled {
completion(error: error ?? NSError(domain: "Facebook Login Failed", code: -1, userInfo: nil))
}
In above call, I see error equal to nil but result.isCancelled is set to true. 在上面的调用中,我看到错误等于nil,但result.isCancelled设置为true。
I checked other thread listed below similar to this, and I am sure that all calls related to Facebook are their and working fine. 我检查了下面列出的与此类似的其他线程,并且我确定所有与Facebook有关的调用都可以正常工作。
This is happening for iOS 8 and 9 as well and this was working when developed first time. iOS 8和9也会发生这种情况,并且在首次开发时就可以使用。
Current API version “4.12.0", Xcode version - Version 7.3 (7D175), iOS 8.0 and 9.0 If I use iOS 8, I see weird response on Safari webpage. 当前的API版本“ 4.12.0”,Xcode版本-版本7.3(7D175),iOS 8.0和9.0如果使用iOS 8,我在Safari网页上看到奇怪的响应。
Any clue/hint will be greatly appreciated. 任何线索/提示将不胜感激。 Let me know if you need to know anything further.
让我知道您是否需要进一步了解。
You need to implement the callback method in AppDelegate. 您需要在AppDelegate中实现回调方法。
UIApplicationDelegate
's application:openURL:options:
for iOS 9.0 and above. UIApplicationDelegate
的application:openURL:options:
适用于iOS 9.0及更高版本。 application:openURL:sourceApplication:annotation:
for iOS 8.0. application:openURL:sourceApplication:annotation:
适用于iOS 8.0。
The question is already answered here: Facebook SDK login never calls back my application on iOS 9 这个问题已经在这里得到解答: Facebook SDK登录从不回叫我在iOS 9上的应用程序
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.