platanus / cordova-gigya

Cordova plugin that handles Gigya integration for mobile (iOS and Android) apps.
4 stars 4 forks source link

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
Example
cordova.plugins.CordovaGigya.initialize(apiKey)

showLoginUI

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

Parameters
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
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
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
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
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.