Show TOC

init( successCallback, errorCallback, applicationId, [context], [logonView], [certificateProviderClassName] ) methodLocate this document in the navigation structure

Initialization method to set up the Logon plugin.

This will register the application with the SMP server and also authenticate the user with servers on the network. This step must be done first prior to any attempt to communicate with the SMP server.


            


This function and sap.Logon.initPasscodeManager are mutually exclusive.  Do not call both.
Syntax

<static> init( successCallback, errorCallback, applicationId, [context], [logonView], [certificateProviderClassName] )

Parameters
Name Type Argument Default Description
<successCallback> sap.Logon~successCallback     The function that is invoked if initialization is successful.The current context is passed to this function as the parameter.
<errorCallback> sap.Logon~errorCallback     The function that is invoked in case of an error.
<applicationId> string     The unique ID of the application.Must match the application ID on the SAP Mobile Platform server.
<context> object (optional)   The context with default values for application registration.See sap.Logon~successCallback for the structure of the context object. Note that all properties of the context object are optional, and you only need to specify the properties for which you want to provide default values for. The values will be presented to the application users during the registration process and given them a chance to override these values during runtime. There are two additional values that can be specified in the context that are not described in sap.Logon~successCallback: "mobilePlaceAppID" and "mobilePlaceAppVersion". If left blank, the mobilePlaceAppID will default to the applicationId provided to this function. mobilePlaceAppVersion defaults to "1.0". The mobile place app ID and version are used in combination to retrieve the configuration from Mobile Place.
<logonView> string (optional) sap.logon.IabUi The cordova module ID of a custom renderer for the logon, implementing the [showScreen(), close()] interface.Please use the default module unless you are absolutely sure that you can provide your own custom implementation. Please refer to JavaScript files inside your Kapsel project's plugins\logon\www\common\modules\ folder as example.
<certificateProviderClassName> string (optional)   The name identifying the custom certificate provider to use.This parameter should only be specified if the app is supposed to use a custom certificate provider. In that case, the string specified by this parameter must match the android:name of the meta-data tag in AndroidManifest.xml (the value for that tag will be the classpath and classname).
Example
// a custom UI can be loaded here
var logonView = sap.logon.IabUi;

// The app ID
var applicationId = "someAppID";

// You only need to specify the fields for which you want to set the default.   These values are optional because they will be 
// used to prefill the fields on Logon's UI screen.  
var defaultContext = {
 "serverHost" : "defaultServerHost.com"
 "https" : false,
 "serverPort" : "8080",
 "user" : "user1",
 "password" : "Zzzzzz123",
 "communicatorId" : "REST",
 "securityConfig" : "sec1",
 "passcode" : "Aaaaaa123",
 "unlockPasscode" : "Aaaaaa123"
};

var app_context;

var successCallback = function(context){
    app_context = context;
}

var errorCallback = function(errorInfo){
    alert("error: " + JSON.stringify(errorInfo));
}
sap.Logon.init(successCallback, errorCallback, applicationId, defaultContext, logonView, "customCertProvider");