(solved) listener is not being called (although post is made)

On the Corona Facebook Sample code, if we remove the line 310 of the main.lua which is:

enforceFacebookLogin()

what makes the app try to login right after the app opens and then press the share buttons (lke the “Post Photo” or “Share Link Dialog”), the post is made with success (I can see on my timeline) but the facebook listener inside the app is not called.

Why is that?

On my app I have a share button and I only want to call the FB login if the user taps on the share button, not before. So today I am not getting the listener back.

Hi Renato - Red Beach,

The facebook listener won’t be called unless it’s explicitly assigned in code. In the old facebook plugin, you had to pass the listener as a parameter to facebook.login(). This is now an optional argument in Facebook-v4.

Alternatively, you can use the new facebook.setFBConnectListener() API to do this.

Most importantly, be sure that you’ve set the listener by either of the above means before calling facebook.request() or facebook.showDialog().

Furthermore, the enforceFacebookLogin() method in the Facebook Sample will skip any calls to facebook.login() if a user access token has already been found, which will happen on repeated launches if you don’t call facebook.logout().

@Ajay, you nailed. Thanks for help.

Hi Renato - Red Beach,

The facebook listener won’t be called unless it’s explicitly assigned in code. In the old facebook plugin, you had to pass the listener as a parameter to facebook.login(). This is now an optional argument in Facebook-v4.

Alternatively, you can use the new facebook.setFBConnectListener() API to do this.

Most importantly, be sure that you’ve set the listener by either of the above means before calling facebook.request() or facebook.showDialog().

Furthermore, the enforceFacebookLogin() method in the Facebook Sample will skip any calls to facebook.login() if a user access token has already been found, which will happen on repeated launches if you don’t call facebook.logout().

@Ajay, you nailed. Thanks for help.