init( successCallback, errorCallback, applicationId, [context], [logonView] ) method

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.

Syntax

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

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.
logonView string (optional) "com/sap/mp/logon/iabui" The cordova module ID of a custom renderer for the logon, implementing the [showScreen(), close()] interface.Please use the defaul 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.

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"
\t"https" : false,
\t"serverPort" : "8080",
\t"user" : "user1",
\t"password" : "Zzzzzz123",
\t"communicatorId" : "REST",
\t"securityConfig" : "sec1",
\t"passcode" : "Aaaaaa123",
\t"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);

Source

LogonController.js, line 1526.