Skip to content

Cordova plugin that handles Gigya integration for mobile (iOS and Android) apps.

Notifications You must be signed in to change notification settings

platanus/cordova-gigya

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Cordova Gigya

Cordova plugin that handles Gigya integration for mobile (iOS and Android) apps.

Project uses mobile native Gigya SDK for iOS and Androidplat to utilize basic operations for a mobile app that uses Cordova.

Prerequisites

iOS

It's mandatory to use the native Facebook integration, for that we need to use the FacebookSDK.

Download the latest iOS FacebookSDK, and follow the getting started guideline.

Copy the facebook framework to your project folder

cd my_project
cp -R ~/Documents/FacebookSDK/FacebookSDK.framework . 
# This is the default location

Android

It's mandatory to use the native Facebook integration, for that we need to use the FacebookSDK.

  1. Download and extract the latest Facebook SDK for Android, available at https://developers.facebook.com/docs/android
  2. Import the "facebook" folder from the downloaded SDK into your Eclipse workspace.
  3. Under the project properties, navigate to the "Android" tab.
  4. In the lower part of the dialog box, click "Add" and choose the "FacebookSDK" project from the workspace.
  5. If your project already has a copy of android-support-v4.jar, remove one of the copies (either from the Facebook project or from your app's project).

For more info go to the getting started guideline.

Installing the plugin

To add this plugin just type:

cordova plugin add https://github.com/platanus/cordova-gigya --variable FB_APP_NAME=<facebook app name> --variable FB_APP_ID=<facebook app id>

To remove this plugin type:

cordova plugin remove us.platan.gigya

##Usage

The plugin has the following methods:


initialize

Initializes the Gigya SDK and sets your partner API key.

Parameters
  • api_key (string): The Gigya Site api key
Example
cordova.plugins.CordovaGigya.initialize(apiKey)

showLoginUI

Displays a provider selection dialog, allowing the user to login to any of the supported providers.

Parameters
  • providers (array): optional An array of providers name strings that should be displayed on the UI. The list also defines the order in which the icons will be presented.
  • params (object): optional login optional parameters, refer to the gigya native sdk reference to get the posible values.
  • successCallback (function): Called with user info data
  • failureCallback (function): Called with error response
Example
cordova.plugins.CordovaGigya.showLoginUI(
    ['twitter', 'facebook'],
    {
        cid: "context id"
    },
    function(user){
        console.log(user);
    },
    function(error){
        console.log(error)
    })

login

Login the user to a specified provider.

Parameters
  • provider (string): the provider's name that will be used for authenticating the user, e.g. "facebook", "twitter", etc.
  • params (object): optional login optional parameters, refer to the gigya native sdk reference to get the posible values.
  • successCallback (function): Called with user info data
  • failureCallback (function): Called with error response
Example
cordova.plugins.CordovaGigya.login(
    "twitter", 
    null,
    function(user){
        console.log(user);
    },
    function(error){
        console.log(error)
    })

logout

Logs out from Gigya and clears the saved session.

Parameters
  • successCallback (function): Called after logged out
  • failureCallback (function): (IOS only) Called with error response
Example
cordova.plugins.CordovaGigya.logout(
    function(){
        console.log("logged out");
    },
    function(error){
        console.log("ios error");
        console.log(error);
    })

sendRequest

Sends a request to Gigya server. This method is used for invoking any of the methods supported by Gigya's REST API.

Parameters
  • method (string): Name of the method to be called
  • params (object): optional Optional parameters for methods that require them
  • successCallback (function): Called with request response
  • failureCallback (function): Called with error response
Example
cordova.plugins.CordovaGigya.sendRequest(
    "socialize.getSessionInfo",
    {
        provider: "twitter"
    },
    function(user){
        console.log(user);
    },
    function(error){
        console.log(error)
    })

getSession

Retrieves the current session.

Parameters
  • successCallback (function): Called with session token
  • failureCallback (function): Called when error
Example
cordova.plugins.CordovaGigya.showLoginUI(
    function(token){
        console.log(token);
    },
    function(){
        console.log()
    })

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Credits

Thank you contributors!

Platanus

cordova-gigya is maintained by platanus.

License

Apache License Version 2.0.

About

Cordova plugin that handles Gigya integration for mobile (iOS and Android) apps.

Resources

Stars

Watchers

Forks

Packages

No packages published