Last modified 16:12, 16 Mar 2015


This utility method allows you to wait for a service to finish its initialization process before using it. When the required service is ready to be used the callback function is executed. If the service is already ready when you call the waitForService method, then the callback is executed immediately.

Use this method as a wrap-around the service usage, for example:

gigya.socialize.waitForService(conf, {service: 'facebook', callback: function(response) {
        // Service is ready
        // Use the service here 
    } });


Using Facebook JS SDK

In order to use the Facebook JS SDK the following requirements must be fulfilled:

  1. Define a CNAME entry in your DNS server: specify a new subdomain in your site and point it to
  2. In the Gigya's Site setup page, make sure to configure a domain alias (CNAME) and in Gigya's Permissions page, enable Native SDK.
  3. Open an external application in Facebook. When configuring the external application make sure to follow the instructions for sites using a domain alias, namely, paste your CNAME subdomain instead of in all the places that require a callback URL.
  4. In your page, when loading gigya.js, make sure to pass your APIKey as a parameter (read more in Gigya Basics):
    <script type="text/javascript" src="" ></script>
  5. Use the socialize.waitForService method, to ensure that the Facebook service is ready to be used (see the code sample below).





Method Parameters

The following table lists the params object members:

Required Name Type Description
Required service string The service for which to wait. Currently only "facebook" is supported for use with this parameter.
  callback function A reference to a callback function. Gigya calls the specified function along with the response when the requested service is ready to be used. If the service is already ready when you call the API method, then the callback is executed immediately.
The callback function should be defined with the following signature: functionName(response)
The "Response object Data Members" table below provides specification of the data that is passed to the callback function.
Optional context object A developer-created object that is passed back unchanged to the application as one of the fields in the response object.


Response Object Data Members

Field Type Description
errorCode integer The result code of the operation. Code '0' indicates success, any other number indicates failure. For a complete list of error codes, see the Error Codes table.
errorMessage string A short textual description of an error associated with the errorCode for logging purposes.
operation string The name of the API method that generated this response.
context object The context object passed by the application as parameter to the API method, or null if no context object has been passed.


Triggered Global Events

See Events for more infromation.


facebookLoaded Event Data

Field Type Description
eventName string The name of the event: 'facebookLoaded'.
isLoggedIn Boolean Specifies whether the user is logged in.
isConnected Boolean Specifies whether the user is connected.


Code Sample

gigya.socialize.waitForService({service: 'facebook', callback: function(response) {
        // facebook Service is ready to be used. Facebook API usage comes here:
        FB.ui( {method: 'stream.share'}, function(){} ); 
} });

  • This sample is not meant to be fully functional code. For brevity's sake, only the code required for demonstrating the API call itself is presented.
  • To run the code on your own domain, add your Gigya API key to the socialize.js URL. A Gigya API key can be obtained on the Site Dashboard page on Gigya's website. Please make sure that the domain from which you are loading the page is the same domain name that you used for generating the API key.
  • In some cases it is necessary to connect/login the user to a provider? prior to calling the API method. You can learn more in the Social Login guide.

Page statistics
612 view(s) and 6 edit(s)
Social share
Share this page?


This page has no custom tags.
This page has no classifications.


You must to post a comment.