Brent Roberts
Brent Roberts

Reputation: 1

JavaScript SDK events don't fire

I am using the JS SDK to tie into facebook. After initialization (FB.init()), I see the Login button. After clicking it, it prompts me to login. Then the dialog just goes away after I log in, despite the fact that I am using FB.Event.subscribe() to add a handler to the auth.login event.

Note that I include the Facebook all.js file using a tag in html which is processed prior to this code.

here is my code:

FB.init({

                            appId:myId,
                            channelUrl:myChannelUrl,
                            cookie:true,
                            status:true,
                            xfbml:true
                     });
            FB.Event.subscribe('auth.login',function(response) {
                            alert("your event finally fired!!!");
            });
            FB.Event.subscribe('auth.logout',function(){
                    alert("you logged out");
            });

Now, when I log in or log out, NOTHING happens. The facebook dialog simply goes away. If I purposely use incorrect credentials to attempt log in, the dialog properly rejects the attempt, which proves that the thing is indeed communicating with facebook. The trouble seems to be that the event is not firing.

thank you for any guidance here.

Upvotes: 0

Views: 764

Answers (1)

Anirudh Ramanathan
Anirudh Ramanathan

Reputation: 46728

Subscribe to this event instead.

FB.Event.subscribe('auth.statusChange', handleStatusChange);    

and in your javascript,

function handleStatusChange(response) {
if(response.authResponse ==  'connected')
//do something
else
//do something else
}

Ref: http://www.facebookmobileweb.com/hello/

Upvotes: 1

Related Questions