Facebook SDK Version 4.17.0 isn't working

When we upgrade our Facebook SDK to version 4.17.0 from 4.15.1, Facebook login stops working. The token is always returned as nil.

The token which is returned by a call to the Facebook API?

token is nil

ERROR: token = nil

This is the error that we see in the console. This is the token that is returned by Facebook I believe. But this same code works perfectly when we use version 4.15.1 of the FB SDK.

This is the part of our code (in the app delegate) that is triggering that return in the console.

let token = FBSDKAccessToken.current()

            print ("token is \(token)")

            if token == nil {

                print("ERROR: token = \(token)")

                return false

            }



Could you please help me understand how this is related to Backendless? If you make a direct call to FB API and get nil back, what does it have to do with Backendless?

I am not sure if it is related to backendless. I just thought it would be helpful to let everyone know that this problem exists when using the latest version of the FB SDK for login.

It could be the code that we are using. We are using the same code from the sample application that you sent to us. When we have the FB SDK version 4.15.1, it is working perfectly fine but when we update to version 4.17.0 it is returning nil. I tried to check if others saw the same issue online but I didn’t find much.

I see. Try isolating the problem by creating a minimalistic app that uses just FB SDK. If the problem does not happen there, expand the project with other dependencies and see which one make the difference (if any). If it continues to work, then the problem must be somewhere with the code.

I did that and attached the sample project I used here. It still returns the same error. This is the same sample project that Vyacheslav gave us for Facebook login using swift 3. The only change I made here was that I updated the FB SDK and the Backendless SDK to their most current versions using pods.

TestS3FacebookSDKLogin 2.zip (20.18MB)

Does the problem occur in this project if you exclude the Backendless pod?

Even when we got rid of the Backendless SDK, the same error was displayed which means it is an issue with the code. If you have updated code for use with the FB SDK, we would love to use that instead. The reason we are looking into this is because of an issue with a black screen that is appear sometimes when we try to login with the facebook SDK.

Please let us know when you resolve it and what the resolution was so others can benefit from the information. For now, I’ll mark this topic as “Not a problem”, since technically it is not related to Backendless.

Nevin, you should return FB SDK 4.15.1 because 4.17.0 has this bug. See this comment in another thread.

I have opened a ticket with FB support team to investigate the issue. I will keep this forum updated on the status.

Here is the response I got from the FB team about this. I hope this is helpful.

1/ To run in simulator, you do need to enable Keychain Sharing due to a bug in Xcode (http://stackoverflow.com/questions/39786577/facebook-sdk-login-doesnt-work-on-simulator-on-ios-10-xcode-8)

2/ The Podfile is out of date with current Cocoapods. You must specify the target, here’s the Podfile I used:
target ‘TestS3FacebookSDKLogin’ do
pod ‘FBSDKCoreKit’, ‘4.17.0’
pod ‘FBSDKLoginKit’, ‘4.17.0’
pod ‘FBSDKShareKit’, ‘4.17.0’
pod ‘Backendless’
end

3/ The sample uses the result of FBSDKApplicationDelegate.sharedInstance().application(…) to determine if it should check for a current access token. This is not guaranteed behavior (though it appeared to work in the sample when tested). Instead, you should be checking for the token after the appropriate callback has been called. Since you’re using FBSDKLoginButton, you should assign a delegate to check for the login results. (alternatively, you can use FBSDKLoginManager which has block based callbacks).

3/ The sample returns false if there is no token in func application(_ app: UIApplication, open.... You should not return false, as that would signal to iOS that URL was not handled but if result is true, then it was handled.

Additionally you should try to reference our documentation for Swift SDK here for further assistance.
https://developers.facebook.com/docs/swift

I spoke to the Facebook team and they provided me with a sample application of how the FB SDK should be used with backendless. Let me know if this is helpful. It does not seem like there is anything wrong on their end.

10000000_211254402659785_5690116387641491456_n.zip (20.23MB)