Show TOC

Adding the Logon PluginLocate this document in the navigation structure

To install the Logon plugin, use the Cordova command line interface.

Prerequisites

  • Set up the development environment.
  • Create your Cordova project.
  • Add your OS platforms.

Procedure

  1. Add the plugin, by entering, at the command prompt:

    cordova plugin add kapsel-plugin-logon --searchpath KAPSEL_HOME/plugins

    Note KAPSEL_HOME=C:\SAP\MobileSDK3\KapselSDK.
  2. (Optional) To see a list of installed plugins in your Cordova project, open a command prompt or terminal window, navigate to your Cordova project folder, and enter:
    cordova plugins
    The Cordova command line interface returns a JSON array showing installed plugins, for example:
    [ 'kapsel-plugin-corelibs',    
    'kapsel-plugin-logon',    
    'cordova-plugin-console',    
    'cordova-plugin-device',
    'cordova-plugin-device-orientation',    
    'cordova-plugin-dialogs',    
    'cordova-plugin-inappbrowser' ] 

    In this case, some core Cordova plugins were added, including corelibs, console, device, device-orientation, dialogs, and inAppBrowser. CoreLibs is a utility plugin that is automatically added to every Kapsel project by the command line interface, so you need never add the CoreLibs plugin to a project manually.

  3. Configure the application (type: hybrid) in the cockpit.
  4. Define a variable in the JavaScript code (typically, this is done in the index.html file of your Cordova application) to describe the app ID, for example:
    var appId = "com.sap.kapsel.mykapselapp";
    Kapsel uses an app ID to tell the server which application definition on the server to use for this application. The app ID that is defined on the server must match what is entered here.
  5. For Windows projects, acquire the WinJS 4.4 library from the WinJS site (http://try.buildwinjs.com/) and include it in the index.html file. Reference the base.js and ui.js script files, and the ui-light.css stylesheet. There is more than one way to do this, as detailed on the WinJS Web site.
  6. Define the connection to the server, for example:
    var defaultContext = {    
         "serverHost" : "192.168.254.159",    
         "https" : "false",    
         "serverPort" : "8080",  
         "resourcePath": "Enter URL suffix",    
         "farmId": "Enter name of company id",   
    }; 
    This prepopulates the fields in the registration dialog that is shown to users during the initialization process.
  7. Make a call to the Logon plugin’s init method as shown:
    //Make call to Logon's Init method to get things registered and all set up  
    sap.Logon.init(logonSuccess, logonError, appId, defaultContext); 
    The init method gathers information about the environment’s security configuration by asking the Afaria client and Client Hub application, if available, sets up and configures the DataVault, connects to the server to register the application connection and authenticate the user. As part of this process, the appropriate screens are shown to gather user input and manage the entire process.
  8. Use the Android IDE, Xcode, or Visual Studio to deploy and run the project.
    Note If you are deploying to an iOS device, in Xcode, you must add the clienthubEntitlements and $(CFBundleIdentifier) to the keychain group in the Entitlements section as well as the bundle identifier.

    CFBundleIdentifier
  9. Verify the registration in the cockpit.
    1. Log in to the cockpit.
    2. Click Applications.
    3. Click Registrations.
      You can see the registration ID following a successful registration.

      verify_register_logon