- Gigya's Cordova SDK supports:
- The Gigya Cordova plugin is built for:
- Implementing social provider authentication in your app requires the latest native SDK of the social provider (Google/Facebook) for the necessary platform.
The Gigya Cordova SDK requires Cordova. You can use either of the supported platforms listed above for development with our SDK.
To get started with your first app, follow these steps.
Gigya Setup - Obtain Your Gigya API Key
Important: Please make sure to check the Enable mobile or desktop client applications API access checkbox in the Permissions page.
Download The Gigya Cordova SDK Plugin
Download the Gigya Cordova SDK from the following link:
You should save the downloaded file to the location you want to store the plugin for use with your app.
Install Cordova (http://cordova.apache.org/) or one of the other supported platforms.
If you are using one of the other supported platforms, be sure to adjust the following code examples to reflect the correct platform name. These instructions assume you are using Cordova.
Create your new app
Change to the new directory for your app.
Edit your unique widget id in the config.xml file that was created.
If you edit this widget ID at any time after installing the Gigya plugin (in the following step), you will need to re-install the Gigya Cordova plugin.
Add any required platforms.
After adding your required platforms, edit your unique widget id in the config.xml file that was created.
Add any required plugins.
For supporting both Facebook and Google Native Login all the above plugins are required.
The Reverse Client ID required for Google, is your Google App ID re-ordered in reverse, i.e., if your app id is 12345678901234567890.apps.googleusercontent.com your reverse client id would be com.googleusercontent.apps.12345678901234567890
Using Google Sign-In requires signing your APK with a SHA-1 fingerprint. For instructions on obtaining this fingerprint, see https://developers.google.com/android/guides/client-auth.
Set the minimum versions inside your config.xml file to avoid exceptions.
For Android add to the platform definition: <preference name="android-minSdkVersion" value="15" />
For iOS add to the platform definition: <preference name="deployment-target" value="7.0" />
Ensure that Android was installed correctly
Check Gradle and ensure that you have a listing for Android. If you do not, follow the below steps to ensure that Android support is properly installed.
This step is necessary even if you are not using Google Native Login.
Steps to resolve:
- Open Android Studio.
- Select "Open an existing Android Studio project".
- Select the "android" folder that is located within the cordova project > platforms.
- Right click on "app" module > Open module settings.
- Navigate to dependencies tab.
- Select the "+" sign in the bottom left corner > Library dependency (maven).
- Search for "com.android.support:support-v4".
- Choose the latest suggested entry > OK > OK.
- Sync project gradle file.
- Build application again (make sure to delete previous builds for device/emulator).
Implement A Demo
If you want to implement a demo app, use the following example code.
In the /www/js/index.js file add the following:Expand for code example...
In the /www/index.html file add:Expand for code example...
Ensure that gigyaClient.init() is the very first call your app makes after the device is ready.
gigyaClient.init() must be the first interaction between the Gigya SDK and your app.
The gigyaClient library is automatically installed when building your app by including the cordova-plugin-gigya plugin.
init - Initializes the site configuration. This must be called before any further interaction with the SDK.
- apiKey - string
- apiDomain - string - Your site's Gigya Data Center URL (without protocol)
us1.gigya.com- For the US data center.
eu1- For the European data center.
au1- For the Australian data center.
ru1- For the Russian data center.
cn1- For the Chinese data center.
If you are not sure of your site's data center, see Finding Your Data Center.
Gigya's Cordova SDK does not currently support the Chinese data center.
Ensure that your Google or Facebook app is setup correctly at the social provider's dashboard.
Validate File Structure
Verify that your app's file structure is correct. Ensure that you change the tree to reflect the following structure.
Logging in the User
After gigyaClient.init() the next thing that must be done is login the user.
The first interaction with Gigya after initialization must always be logging in the user. If the user is not logged in, you cannot access their social profile nor perform social activities, such as setting their status. The quickest way to implement logging-in is using the showScreenSet API of the Accounts namespace.
Note that this is called within the SDK as screenSet(), not showScreenSet().
A small number of Loyalty APIs that generate in-page popups, i.e., gm.notifications will not function.
- pluginName - string (required)
params - object (optional)
Though an optional parameter within the SDK, please review the documentation of any add-ons you are using. Any parameters required by the actual API will need to be included here.
- pluginEvents - object - This object contains a list of Add-on events.
- Allowed keys:
- All other plugin events.
- Allowed keys:
- onDismiss - a JS event that can also be triggered from the native scope when the user has canceled the dialog.
- event - object.
When calling specific APIs using a mobile SDK, the plugin name is not always inputted the same as it is for Web or REST.
Whenever you are using an API that begins with 'show', i.e., showScreenSet, showCommentsUI, etc.
- Do not include the 'show' segment of the API name and convert the new first letter of the API to lower-case:
- showScreenSet will be screenSet
showCommentsUI will be commentsUI
*A notable exception to this is socialize.showLoginUI which is still showLoginUI in both Android and iOS SDKs and not currently supported in the Cordova SDK.
loginToProvider - Login to Gigya using the specified provider.
- provider - string (required)
- params - object (optional)
- Returns: Thenable<IResponse>
See also Facebook's LoginBehavior constants.
Additional Provider Configurations
Facebook Native Login
To enable Facebook native login, you must install the plugin located at https://github.com/gigya/cordova-plugin-facebook4.
Follow the plugins instructions for adding it to your app.
Google Native Login
To enable Google native login, you must install the plugin located at https://github.com/gigya/cordova-plugin-googleplus.
Follow the plugins instructions for adding it to your app.
If you do not yet have an active Google app please see our Google documentation.
For mobile specific app creation, please go to:
The SDK handles all session information internally and enables Gigya to maintain the Login State according to your site Policy settings.
Once a user is logged in via the SDK, they will be considered logged in to all available plugins that are then loaded.
Continue to the Cordova SDK Reference for your preferred language:
You can download a Cordova demo project implementing Gigya from the following links:
When using screen-sets via a Gigya Mobile SDK, if you manually change the screen that is is displayed to the user via pluginView, you need to supply the containerID property with the value of pluginContainer, otherwise the screen will not display or an error will be thrown. An example follows: