Reputation: 475
What causes the FB.Event.subscribe event to fire?
I know clicking an fb:login-button element can trigger it but the FB.Event.subscribe event is firing anytime a Facebook session is created.
Do other FBML elements automatically trigger this event when a Facebook session is present or does this event trigger regardless of regardless of any FBML elements present?
Upvotes: 2
Views: 3690
Reputation: 1906
You can only know what triggers each event by looking at the Facebook docs or by looking through the JS SDK source code. Here are links for both of those:
In the JS source, look for calls to FB.Event.fire( ... ). You may have to do some more analysis to figure out the exact conditions, especially since my version of the JS is from a minified version of the SDK. Facebook does not release their actual source at this time so we have to make do with de-minifying the final SDK.
Upvotes: 1
Reputation: 1630
I had this same issue, but the solution I found was:
FB.init
, set the parameter status to false (in almost all samples I saw it comes as true by default)So you'll end with something like it:
<script>
window.fbAsyncInit = function () {
FB.init({
appId: 'YOUR-APPID',
channelUrl: '//www.YOUR-DOMAIN.com/channel.html',
status: false,
cookie: true,
xfbml: true
});
FB.Event.subscribe("auth.statusChange", function (response) {
if (response.authResponse)
{
if (FBLoginCallback) FBLoginCallback();
}
});
};
(function (d) {
var js, id = 'facebook-jssdk'; if (d.getElementById(id)) { return; }
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/pt_BR/all.js";
d.getElementsByTagName('head')[0].appendChild(js);
} (document));
</script>
Notice that I made a callback function named FBLoginCallback(), so I can use this code in a MasterPage, and define the callback handling function in separated pages, each with its specific needs.
Upvotes: 2
Reputation: 38135
FB.Event.subscribe
by itself is not an event, it's just like the addListener where it hook an event to a function. You need to check your code to see what events you are using:
I suppose you have the auth.sessionChange
event used.
Upvotes: 5