Configuring Default Values

Add JavaScript to configure default logon settings.

  1. Go to the <Project Name>/www folder and open the file where you want to add the JavaScript, for example, index.html.
  2. Add your code, for example:
    function logonSuccessCallback(context) {
                    console.log("logonSuccessCallback " + JSON.stringify(context));
                }
                
                function errorCallback(e) {
                    alert("An error occurred");
                    alert(JSON.stringify(e));
                }
    
            function deviceReady() {
                    
                    var appId = "theAppId"; // Change this to app id on server
                    
                    // Optional initial connection context
                    var context = {
                        "serverHost": "example.com",
                        "https": "false",
                        "serverPort": "8080",
                        "communicatorId": "REST",
                    };
                    sap.Logon.init(logonSuccessCallback, errorCallback, appId, context);
                }
    
                document.addEventListener("deviceready", deviceReady, false); 
    This example shows the call to the sap.Logon.init function, as well as the success and error callbacks that are passed to the sap.Logon.init function. It also shows how you can make sure the registration process is started as soon as possible by attaching a listener to the deviceready event. Inside the deviceReady function, the app ID and the context are defined.
  3. Save the file.