loginWithFacebookSDK not setting currentUser for IOS


After obtaining the Facebook access token successfully, I tried to login using backendless.userService.loginWithFacebookSDK(token, fieldMapping: [“id” : “facebookId” ,“name” : “name” ,“email” : “email”], response:…

After this code gets executed successfully without error (could tell from the block), I can see that the facebookId, name and email get stored in the backendless database under Data/User. (As expected)

However, when I try to print out backendless.userService.currentUser, the print statement crash while trying to retrieve backendless.userService.currentUser. Even when I try to do

if let user = backendless.userService.currentUser { print(user) }
else {print(“Error”)}

this code crashes when trying to run the first line.

Could anyone please advise what is happening here?

Hi, Edward!

We’ll investigate this and get back to you.
Internal ticket number - BKNDLSS-12679

This issue has been fixed. Please update the latest Backendless SDK by CocoaPods (3.0.23 release) or from ios-SDK github (CommLibiOS and backendless with them ‘include’ folders)

After doing so, the issue disappeared. One small thing is that the backendless.userService.currentUser does not seem to immediately get registered with the Facebook detail. I had to wait for approximately 3 seconds after the Facebook screen dismisses before currentUser.name prints out my name rather than null. Not sure if it is my code’s problem or the server’s problem But the big problem is fixed so I’m satisfied. Thanks.

You could try our UserSocial sample from iOS-Samples github, and compare it with your app working.