init_fb_connect(..., :app_settings => "{a: 'valid', json: 'string'}")
init_fb_connect can accept an :app_settings option to integrate come call backs triggered by the user's connected state. (FB Wiki)reloadIfSessionStateChanged
If reloadIfSessionStateChanged is set to true (default is false) Facebook will monitor changes in session state and reload current page if session state changes. This option is convenient for application that needs to reload page whenever session state change in order to generate different content from server side. Click here for a demo.Examples:
:app_settings => "{reloadIfSessionStateChanged: true}"
ifUserConnected / ifUserNotConnected
These parameters can be either a function that takes a string argument for uid or string to a url. If a function is passed, then the function would be invoked. If a string is passed, then the browser will be redirected to the url specified in the string. Note these key and reloadIfSessionStateChanged cannot be specified at the same time. Click here for a demo.It is my experience that the ifUserConnected callback is called *twice* if the page utilizes Facebook Comments. I have no documentation of this other than testing this very site with a simple javascript call back that pops an alert. If connected, a popup appears on page load, then shortly therafter another popup appears. Removing the Facebook comment widget at the bottom of the page results in only a single callback being made. I assume the same would happen if a URL is provided. Keep this in mind when developing the call back.
The documentation seems to suggest that these callbacks are triggered on connect status changes. That doesn't seem to be the case. They are called every time the page loads. Also, if I am connected to this site, then logout of Facebook in another tab, nothing happens on this original page. I must reload the page for it to notice the change.
Examples:
:app_settings => "{ifUserConnected: javascript_function_connected, ifUserNotConnected: javascript_function_not_connected}"
:app_settings => "{ifUserConnected: '/connected/url', ifUserNotConnected: '/notconnected/url'}"
Comments