Facebook Login Listener Issue

When calling the Facebook Login API, the listener appears to be called N times, where N is the number of times you’ve called the Login API. For example:

  1. Log the user in with facebook.login().
  • Listener is called.​
  1. Log them out with facebook.logout().
  2. Log them in again with facebook.login().
  • Listener is called.
  • Listener is called again.

My guess is each time you call facebook.login(), it takes the supplied listener and stores it, calling it any time there is an event to report. The trouble is, when you call facebook.login() a second, third, or fourth time, you get three, four, or five listener calls. I’d just not supply the listener after the first time, but it is a required parameter. I also don’t see anyway to remove the listener. Is this a bug, or am I missing something?

OS: iOS 7.0.4

Device: iPad, 3rd generation

Build: CoronaEnterprise 2013.2087

Hi Daniel,

Can you post your basic listener code for us to inspect? Did you follow through this entire guide?

http://docs.coronalabs.com/guide/social/implementFacebook/index.html

Thanks,

Brent

Certainly.

 function group:login() print('login') facebook.login(Constants.FACEBOOK\_APP\_ID, function(event) print('facebook listener called: ' .. utils.printTable(event)) if event.type == "session" and event.phase == "login" then self:updateFacebookToken(event.token) elseif event.type == "request" then local data = json.decode(event.response) if data then self:saveFBData(data) else self:error() end else self:error(event) end end, {"publish\_actions", "email", "user\_birthday"}) end function group:logout() print('logout!') self:setFacebookToken(false) facebook.logout() end

The order of calls is: group:login(), group:logout(), group:login()…The resulting output is:
 

2013-11-22 15:56:22.649 app[3224:60b] login

**2013-11-22 15:56:22.660 app[3224:60b] facebook listener called: {****type=“session”,name=“fbconnect” **,expiration=1390161891,phase=“login”,token="…

2013-11-22 15:56:32.902 app[3224:60b] logout!

2013-11-22 15:56:44.384 app[3224:60b] login

**2013-11-22 15:56:44.387 app[3224:60b] **facebook listener called: { type=“session”,name=“fbconnect”, expiration=1390161 891 ,phase=“login”,token="…

**2013-11-22 15:56:44.395 app[3224:60b] **facebook listener called: { type=“session”,name=“fbconnect”, expiration=1390161 891 ,phase=“login”,token="…

I’m relatively new to Lua, so there could be some subtlety about how it is being scoped that I don’t understand, but I also tried not using an anonymous function and it didn’t seem to make a difference.

I took the simple App template provided with Corona Enterprise, added the Facebook Library and a simple login / logout flow similar to what I described above. The project is also in a git repo, so you can see the steps I took to replicate it.

Any guidance on a fix or workaround for preventing this from happening?

See and run the attached code for replicated issue…Thanks!

This issue is still present in Corona Enterprise 2013.2096.

Hi,

This issue will be fixed in daily build 2098.  Thanks for reporting the issue.

Awesome, dchan! Thanks. I just tested 2099, and verified it is fixed. Thanks for the prompt response and fix. Any update on this issue? I’ve seen it as well.

Hi Daniel,

Can you post your basic listener code for us to inspect? Did you follow through this entire guide?

http://docs.coronalabs.com/guide/social/implementFacebook/index.html

Thanks,

Brent

Certainly.

 function group:login() print('login') facebook.login(Constants.FACEBOOK\_APP\_ID, function(event) print('facebook listener called: ' .. utils.printTable(event)) if event.type == "session" and event.phase == "login" then self:updateFacebookToken(event.token) elseif event.type == "request" then local data = json.decode(event.response) if data then self:saveFBData(data) else self:error() end else self:error(event) end end, {"publish\_actions", "email", "user\_birthday"}) end function group:logout() print('logout!') self:setFacebookToken(false) facebook.logout() end

The order of calls is: group:login(), group:logout(), group:login()…The resulting output is:
 

2013-11-22 15:56:22.649 app[3224:60b] login

**2013-11-22 15:56:22.660 app[3224:60b] facebook listener called: {****type=“session”,name=“fbconnect” **,expiration=1390161891,phase=“login”,token="…

2013-11-22 15:56:32.902 app[3224:60b] logout!

2013-11-22 15:56:44.384 app[3224:60b] login

**2013-11-22 15:56:44.387 app[3224:60b] **facebook listener called: { type=“session”,name=“fbconnect”, expiration=1390161 891 ,phase=“login”,token="…

**2013-11-22 15:56:44.395 app[3224:60b] **facebook listener called: { type=“session”,name=“fbconnect”, expiration=1390161 891 ,phase=“login”,token="…

I’m relatively new to Lua, so there could be some subtlety about how it is being scoped that I don’t understand, but I also tried not using an anonymous function and it didn’t seem to make a difference.

I took the simple App template provided with Corona Enterprise, added the Facebook Library and a simple login / logout flow similar to what I described above. The project is also in a git repo, so you can see the steps I took to replicate it.

Any guidance on a fix or workaround for preventing this from happening?

See and run the attached code for replicated issue…Thanks!

This issue is still present in Corona Enterprise 2013.2096.

Hi,

This issue will be fixed in daily build 2098.  Thanks for reporting the issue.

Awesome, dchan! Thanks. I just tested 2099, and verified it is fixed. Thanks for the prompt response and fix. Any update on this issue? I’ve seen it as well.

Thanks for posting. I spent a ton of time trying to figure this one out.

Thanks for posting. I spent a ton of time trying to figure this one out.