A PhoneGap plugin for the Creative SDK User Authentication component.
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Added contributor-gls. Aug 16, 2016
docs Fix type in API docs Aug 26, 2016
spec Update tests Aug 23, 2016
src Fix tests Apr 7, 2016
www Fix type in API docs Aug 26, 2016
.editorconfig Login/logout for iOS Apr 6, 2016
.gitignore Login/logout for iOS Apr 6, 2016
.jshintrc Login/logout for iOS Apr 6, 2016
.npmignore Prepare for 1.0.0 release Aug 18, 2016
CHANGELOG.md Update CHANGELOG Aug 26, 2016
LICENSE Issue #12: Add LICENSE file Sep 20, 2016
README.md Update README.md Sep 7, 2016
package.json Issue #12: Add LICENSE file Sep 20, 2016
plugin.xml Bumping plugin version to 1.0.0 Aug 26, 2016

README.md

phonegap-plugin-csdk-user-auth

Stories in Ready

The Creative SDK User Auth UI component provides a solution for developers seeking to allow their users to login to the Adobe Creative Cloud.

This plugin makes it possible for you to use the Creative SDK User Auth UI component in your PhoneGap apps. Read on to learn how!

Contents

Prerequisites

Required: You must first install the Client Auth plugin for this plugin to work.

Required: This guide will assume that you have installed all software and completed all of the steps in the Client Auth guide.

Installation

Adding the plugin

Use the command below to add the plugin to your app.

phonegap plugin add --save phonegap-plugin-csdk-user-auth

Downloading the Creative SDK

iOS

To get the iOS SDK, go to the Downloads page, click the download link for STATIC FRAMEWORKS (DEPRECATED), and extract it to the src/ios folder of this plugin. Extracting the ZIP will create an AdobeCreativeSDKFrameworks folder.

The ZIP files contain all the frameworks in the Creative SDK, but for this plugin we will only be using the AdobeCreativeSDKAssetModel.framework.

Android

No action is required for Android. The Creative SDK for Android is delivered as a remote Maven repository, and the required framework will be downloaded automatically by the plugin.

Setup guide

  1. cd into your existing PhoneGap app (must already include Client Auth)
  2. Add this plugin (see "Adding the plugin" above)
  3. iOS only: download and add the Creative SDK to this plugin's src/ios directory (see "Downloading the Creative SDK" above)
  4. Build and run for your platform

Sample code

www/index.html

Add two buttons within the body. The PhoneGap "Hello World" example includes a div with an ID of app, so for this example, we are including it in there.

// ...

<div class="app">

	// ...

    <button id="login">Login</button>
    <button id="logout">Logout</button>
</div>

// ...

www/js/index.js

Note: Most of the code below comes from the PhoneGap "Hello World" example, and we are providing it here for context.

This plugin provides access to a global CSDKUserAuth object.

The CSDKUserAuth object exposes .login() and .logout() functions.

See comments #1-3 below for relevant code:

var app = {
    initialize: function() {
        this.bindEvents();
    },
    bindEvents: function() {
        // ...

        /* 1) Add click handlers for your buttons */
        document.getElementById('login').addEventListener('click', this.login, false);
        document.getElementById('logout').addEventListener('click', this.logout, false);
    },
    onDeviceReady: function() {
        app.receivedEvent('deviceready');
    },
    receivedEvent: function(id) {
        // ...
    },

    /* 2) Make a helper function to log in to Creative Cloud */
    login: function() {

    	/* 2.a) Prep work for calling `.login()` */
        function success(userObject) {
            console.log("Login Success!", userObject);
        }

        function error(error) {
            console.log("Error!", error);
        }

        /* 2.b) Launch User Auth UI */
        CSDKUserAuth.login(success, error);
    },


    /* 3) Make a helper function to log out from Creative Cloud */
    logout: function() {

    	/* 3.a) Prep work for calling `.logout()` */
        function success() {
            console.log("Logout Success!");
        }

        function error(error) {
            console.log("Error!", error);
        }

        /* 3.b) Log out user */
        CSDKUserAuth.logout(success, error);
    }
};

API guide

See the full API guide.