kony.application Namespace
The kony.application namespace contains the following constants and functions that you can use to manage many aspects of your applications.
Constants
The kony.application namespace provides the following constants.
These application constants are available from V8 SP3 onwards.
| Constant | Description |
|---|---|
| kony.application.APP_LAUNCH_MODE_NORMAL | Constant that identifies if the app was launched in Normal mode. |
| kony.application.APP_LAUNCH_MODE_PUSH | Constant that identifies if the app was launched from push notifications. |
| kony.application.APP_LAUNCH_MODE_URL | Constant that identifies if the app was launched from a deep link. |
| kony.application.APP_LAUNCH_MODE_LIBRARY | Constant that identifies if the app was launched from the library. |
NOTE: The framework sends any one of these application constants in the launchmode property key of the object that is passed as a argument to the appService callback .
The following constants report the status of runtime permissions.
| Constant | Description |
|---|---|
| kony.application.PERMISSION_DENIED | The app does not have permission to access the resource or file. |
| kony.application.PERMISSION_GRANTED | The app has permission to access the resource or file. |
| kony.application.PERMISSION_RESTRICTED | The app has permission to access the resource or file on a restricted basis. |
Functions
The kony.application namespace contains the following functions.
The kony.application.addApplicationCallbacks API helps you to register multiple callbacks for the same event. This API is available from V8 SP4 onwards.
Syntax
kony.application.addApplicationCallbacks(callbacksMap);
Input Parameters
callbacksMap [Object] - Mandatory
Specifies an Object with key as appstate and value as the Map Object (key with value as callback function) for the corresponding appstate. The following appstates are applicable:
| App state | Description |
|---|---|
| isAppLaunchedForInteraction |
State which indicates that the application is visible to users for interaction. isAppLaunchedForInteraction is triggered only once in the lifecycle of the app. If the app is already visible to the user by the time the callback is registered, it is immediately triggered irrespective of whether the app is in the foreground or the background. If the same key is used again, you need to throw a "#APP_STATE# callback with #CALLBACK_ID # key already exists" error message.
|
| onactive | State which indicates that the mobile device is active and the application is running. |
| oninactive | State which indicates that the mobile device is inactive and the application is running. |
| onbackground | State which indicates that the application is active and running in the background. |
| onforeground | State which indicates that the application is active and running in the foreground. |
| onappterminate | State which indicates that the application has been terminated, and has stopped running. |
| onkeyboardchange | State which indicates whether a keyboard is deployed for an application. |
| onpowersourcechange | State which indicates whether a power source is attached to the user's device. |
| onnetworkchange |
|
Example
function functionCallback() {
kony.print alert("====isAppLaunchedForInteraction callback executed====");
}
var callbacksMapObject = {
"isAppLaunchedForInteraction": {“
functionID”: functionCallback
}
};
kony.application.addApplicationCallbacks(callbacksMapObject);
Platform Availability
- Android
- iOS
This API adds a specified key and value to the parameter list of the URL of the form.
Syntax
kony.application.addBMState(formID, key, value);
Input Parameters
| Parameter | Description |
|---|---|
| formID [String] - Mandatory. | Identifier of the form to be bookmarked. |
| key [String] - Mandatory | Key string representing the LHS of the parameter. |
| value [String] - Mandatory | Value string representing the RHS of the key-value combination. The value can not be a nested structure. |
Example
addbookmark: function() {
kony.application.addBMState("Form1", "About", "page2");
alert("A specified key and value are added to the parameter list of the URL");
},Return Values
None.
Platform Availability
- Desktop Web
Using the setGestureRecognizerForAllForms function, you can set a gesture recognizer for all the forms.
Syntax
kony.application.setGestureRecognizerForAllForms (gestureType, gestureConfigParams, nGestureClosure);
Input Parameters
| Parameter | Description |
|---|---|
| gestureType [Number] - Mandatory | Indicates the type of gesture that must be detected on the widget. Following are the possible gestureType values:
|
| gestureConfigParams [object] - Mandatory | Specifies a table that has the configuration parameters that are required to setup a gesture recognizer. The configuration parameters vary based on the type of the gesture. |
| onGestureClosure [function] - Mandatory |
Specifies the function that needs to be executed when a gesture is recognized. This function will be raised asynchronously and has the following signature: onGestureClosure(widgetRef, gestureInfo, context);
|
The gestureConfigParams parameter has the following key-value pairs:
| Gesture Type | Configuration Parameter |
|---|---|
| TAP |
|
| SWIPE |
NOTE: This parameter is applicable only on Android. For example,{fingers:1,swipedistance:50,swipevelocity:75} |
| LONGPRESS |
For example, {pressDuration:1} |
| PAN |
|
| ROTATION |
|
| PINCH |
|
gestureInfo table has the following key-value pairs:
| Key | Description |
|---|---|
| gestureType [number] | Indicates the gesture type |
| gesturesetUpParams [object] | Specifies the set up parameters passed while adding the gesture recognizer |
| gesturePosition [number] |
Indicates the position where the gesture is recognized. Possible values are:
|
| swipeDirection [number] |
Indicates the direction of swipe. Direction is w.r.t the view and not device orientation. This parameter is applicable only if the gesture type is SWIPE. Possible values are:
|
| gestureX [number] | specifies the X coordinate of the point (in pixels) where the gesture has occurred. The coordinate is relative to the widget coordinate system. |
| gestureY [number] | specifies the Y coordinate of the point (in pixels) where the gesture has occurred. The coordinate is relative to the widget coordinate system. |
| widgetWidth [number] | specifies the width of the widget (in pixels). |
| widgetHeight [number] | specifies the height of the widget (in pixels). |
| gestureState[number] |
Indicates the gesture state. The gestureState is applicable only for continuous gestures like PAN, ROTATION, and PINCH.
|
| rotation [number] |
|
| velocityX and velocityY | horizontal and vertical component of velocity expressed in points per second. (Applicable only for PAN gesture type) |
| velocity [number] | velocity of pinch in scale per second. (Applicable only for Pinch gesture) |
| scale [number] | scale factor relative to the points of the two touches in screen coordinates. |
| translationX and translationY [number] | Cumulative distance as number. (Applicable only for PAN gesture type) |
context table has the following key-value pairs:
| Key | Description |
|---|---|
| rowIndex [number] | Row index of the segment UI where gesture is recognized. (Applicable to gestures added to segUI rows) |
| sectionIndex [number] | Section index of the segment UI where gesture is recognized. (Applicable to gestures added to segUI rows) |
Example
//Defining a function
function formGesture(widgetID, gestureInfo) {
var y = kony.type(gestureInfo); //expected value of y = table
var z = kony.type(gestureInfo.gesturesetUpParams); //expected values of z = table
var a = gestureInfo.gestureType;
var b = gestureInfo.gesturesetUpParams;
var c = gestureInfo.gesturePosition;
var d = gestureInfo.gestureX;
var e = gestureInfo.gestureY;
var f = gestureInfo.widgetWidth;
var g = gestureInfo.widgetHeight;
kony.print("*******************************************");
if (kony.os.toNumber(gestureInfo.gestureType) == 2) {
h = gestureInfo.swipeDirection;
kony.print("swipe direction is: " + h);
} else {
h = "";
}
if (kony.os.toNumber(a) == 1) {
b1 = "fingers: " + gestureInfo.gesturesetUpParams.fingers;
b2 = "taps: " + gestureInfo.gesturesetUpParams.taps;
kony.print("" + b1 + "" + b2);
} else if (kony.os.toNumber(a) == 2) {
b1 = "fingers :" + gestureInfo.gesturesetUpParams.fingers;
b2 = "";
kony.print("" + b1 + "" + b2);
} else if (kony.os.toNumber(a) == 3) {
b1 = "pressduration:" + gestureInfo.gesturesetUpParams pressDuration;
b2 = "";
kony.print("" + b1 + "" + b2);
}
kony.print("widget id is: " + widgetID[id]); //will print the widgetID.
//To print widgetID use widgetID.id
kony.print("type of gestureInfo is: " + y);
kony.print("type of gesturesetUpParams is: " + z);
kony.print("gestureType is: " + a); //gestureType=1 or 2 or 3
kony.print("gesturesetUpParams is: " + b.fingers);
/*gesturesetUpParams
= {
fingers = 1, taps = 1
}
or {
fingers = 1, taps = 2
}
or {
fingers = 1
}
or {
pressDuration = 1
}*/
kony.print("gesturePosition is: " + c); //gesturePosition=1 or 2 or 3 or .....9
kony.print("gestureX is: " + d); //ex: gestureX=30
kony.print("gestureY is: " + e); //ex: gestureY=100
kony.print("widgetWidth is: " + f); //ex: widgetWidth=320
kony.print("widgetHeight is: " + g); //ex: widgetHeight=28
//gesturePosition, gestureX, gestureY, widgetWidth, widgetHeight params are not applicable in android
kony.print("*******************************************");
}
function callbackSingleTapGesture() {
var x = {
fingers: 1,
taps: 1
};
try {
kony.application.setGestureRecognizerForAllForms(1, x,
formGesture);
} catch (err) {
alert(typeof err);
alert("error in function callbackSingleTapGesture: " + err.message);
}
}Return Values
String - Reference to the gesture is returned.
Platform Availability
Available on all platforms except Desktop Web.
In some scenarios apps are launched in the background to perform some long running task. A typical example, could be when a watch app requests its parent app (phone app) for some information, the phone app is launched in the background. If the phone app needs to run a long running task in order to serve the requirement of the watch app, it is recommended to start a background task. This API ensures iOS does not suspend the phone app when running in the background that take too much time or resources for execution.
This API is used when you want to run a long running or the asynchronous task in the background of the phone app. When the long running task is completed, you must end the background task using the API kony.application.endBackgroundTask.
Syntax
kony.application.beginBackgroundTask(taskID, callback);
Input Parameters
| Parameter | Description |
|---|---|
| taskID [String] - Mandatory | Specifies the unique identifier for the task. |
| callback [function] - Optional | Specifies the callback that gets executed in the background before iOS suspends the app. You can use this callback to save information or clean up resources before your app gets suspended. |
Example
function ExpirationHandlercallback(){
//your logic to clear resources or save data.
} function jsfunction(userInfo, replyObj){
var taskID = kony.application.beginBackgroundTask("TaskName", ExpirationHandlercallback);
//Long running task.
kony.application.endbackgroundTask(taskID);
}Return Values
This API returns taskID as a number that is used as an input for kony.application.endBackgroundTask API.
Platform Availability
- iOS
Checks and returns the permission status of one or more resources.
Syntax
kony.application.checkPermission(resourceId[constant/String], options[JSObject]);
Input Parameters
| Parameter | Description |
|---|---|
| resourceId [constant/String] - Mandatory | Specify the ID of the resource or name of the permission (only for Android) for which you want to check the status. You can specify either a String (permission name) or an integer (resourceId) value.
The feature to specify the name of the permission as a String is applicable only for Android. For instance, you can query a Native Android permission from the AndroidManifest.xml file by specifying the String directly: "android.permission.READ_PHONE_STATE". |
| options [JSObject] - Optional | Specify the additional option to identify the exact resource of which you want to know the status. This is a platform-specific key. For more information, refer to Resource ID. |
Example 1
var options = {
isAccessModeAlways: true
};
var result = kony.application.checkPermission(kony.os.RESOURCE_LOCATION, options);
if (result.status = = kony.application.PERMISSION_DENIED) {
kony.application.requestPermission();
} else if (result.status = kony.application.PERMISSION_GRANTED) {
kony.location.getCurrentPosition();
}Example 2
< uses - permission android: name = "android.permission.READ_PHONE_STATE" / >
var result = kony.application.checkPermission("android.permission.READ_PHONE_STATE");
if (result.status = = kony.application.PERMISSION_DENIED) {
kony.application.requestPermission();
} else if (result.status = kony.application.PERMISSION_GRANTED) {
kony.location.getCurrentPosition();
}Return Values
JSObject
A JS Object contains the authorization status of the requested resource. The returned JSObject contains the following keys:
| Return value | Description |
|---|---|
| status [constant] | Resource status constant which indicates the overall status of the resource authorization. For more information, refer to Permission Status. |
| canRequestPermission [Boolean] | Indicates whether you can request for the permissions or not in case the value of the status is PERMISSION_DENIED. In the iOS platform, authorization for a resource can be requested only once. For more information, refer to Permission model in iOS. In the Android platform, the app can request for the permissions even though the status return value is PERMISSION_DENIED or direct the user to app settings to turn on or off the authorization. |
Platform Availability
- Android
- iOS
This API provides you the ability to dismiss the loading screen displayed earlier. If there is no loading screen, this API has no affect.
Syntax
kony.application.dismissLoadingScreen();
Example
kony.application.dismissLoadingScreen();
Input Parameters
None
Return Values
None.
Platform Availability
Available on all platforms.
Destroys the target form.
Syntax 1
kony.application.destroyForm(friendlyName);
Syntax 2
kony.application.destroyForm({"appName" : "", "friendlyName" : ""});
Input Parameters
| Parameter | Description |
|---|---|
| appName [String] [Mandatory] |
The name of the app in the project. NOTE: The appName parameter is mandatory in case of inter-app form destroy. |
| friendlyName [String] [Mandatory] |
The friendly name of the form to be destroyed. |
Example 1
kony.application.destroyForm("Form1");
Example 2
The following code snippet deletes the LoginForm in the Accounts app from the Loans app:
kony.application.destroyForm({ "appName" : "Accounts", "friendlyName" : "LoginForm"});
Return Values
None.
Remarks
The function destroys both the target form and its form controller.
This API is invoked when you are done with an execution of long running tasks in the background. The return value of the API kony.application.beginBackgroundTask is used as the input parameter for this API.
Syntax
kony.application.endBackgroundTask();
Input Parameters
| Parameter | Description |
|---|---|
| taskID [Number] - Mandatory |
Specifies the identifier returned by the kony.application.beginBackgroundTask API. |
Example
function ExpirationHandlercallback(){
//your logic to clear resources or save data.
}
function jsfunction(userInfo, replyObj)
{
var taskID = kony.application.beginBackgroundTask("TaskName", ExpirationHandlercallback);
//Long running task.
kony.application.endbackgroundTask(taskID);
}
Return Values
None
Platform Availability
- iOS
This API terminates the application.
Syntax
kony.application.exit();
Example
function exit() {
try {
kony.application.exit();
} catch (Error) {
alert("Exception While getting exiting the application : " + Error);
}
}
Input Parameters
None
Return Values
None
Platform Availability
- Available on all platforms except for Desktop Web.
This API provides you the ability to exit the library. After exiting the library, the control moves to the Native app UI. This API is available from V8 SP3 onwards.
For more information on Library mode, click here.
Syntax
kony.application.exitLibrary();
Example
kony.application.exitLibrary();
Input Parameters
None
Return Values
None.
Platform Availability
- Android
- iOS
NOTE: The kony.application.exitLibrary API is only applicable when the app is launched in Library mode.
This API allows you to read the badge value (if any) attached to the given application icon. If the applications icon does not have any badge value attached to it, this API returns an empty string.
Syntax
kony.application.getApplicationBadgeValue();
Input Parameters
None
Example
gettingBadge: function() {
var badge = kony.application.getApplicationBadgeValue();
alert("The badge value is " + badge);
},
Return Values
| Return Value | Description |
|---|---|
| badgeValue [String] |
Returns the badge value applied to the application icon If the application icon has no badge value attached to it, it returns null/nil. |
Platform Availability
- iOS
This API allows an application on a device to get Push Notifications Settings status. This API takes an object with notification type and callback. Use this API to get the application notification status from device settings.
Syntax
kony.application.getApplicationNotificationSettings (callback);
Example
function getNotificationSettings() {
var callbacksObj = {
notificationType: constants.APPLICATION_UN_NOTIFICATION_TYPE,
callback: notificationCallBack
};
kony.application.getApplicationSettingsForType(callbacksObj);
}
function notificationCallBack(result) {
//Authorization Setting
if (result["authorizationStatus"] == constants.NOTIFICATION_AUTHORIZATION_STATUS_AUTHORIZED) {
alert("authorizationStatus:NOTIFICATION_AUTHORIZATION_STATUS_AUTHORIZED");
} else if (result["authorizationStatus"] == constants.NOTIFICATION_AUTHORIZATION_STATUS_DENIED) {
alert("authorizationStatus:NOTIFICATION_AUTHORIZATION_STATUS_DENIED");
} else if (result["authorizationStatus"] == constants.NOTIFICATION_AUTHORIZATION_STATUS_NOT_DETERMINED) {
alert("authorizationStatus:NOTIFICATION_AUTHORIZATION_STATUS_NOT_DETERMINED");
}
//Notification, Badge, Sound, Alert, LockScreen Settings
var arrSetting = ["notificationCenterSetting", "badgeSetting", "soundSetting", "lockScreenSetting", "alertSetting"];
for (var i = 0; i <= arrSetting.length; i++) {
var setting = arrSetting[i]
if (result[setting] == constants.NOTIFICATION_SETTING_ENABLED) {
alert(setting + ":NOTIFICATION_SETTING_ENABLED");
} else if (result[setting] == constants.NOTIFICATION_SETTING_DISABLED) {
alert(setting + ":NOTIFICATION_SETTING_DISABLED");
} else if (result[setting] == constants.NOTIFICATION_SETTING_NOT_SUPPORTED) {
alert(setting + ":NOTIFICATION_SETTING_NOT_SUPPORTED");
}
}
//Alert Style
if (result["alertStyle"] == constants.NOTIFICATION_ALERT_STYLE_NONE) {
alert("alertStyle:NOTIFICATION_ALERT_STYLE_NONE");
} else if (result["alertStyle"] == constants.NOTIFICATION_ALERT_STYLE_BANNER) {
alert("alertStyle:NOTIFICATION_ALERT_STYLE_BANNER");
} else if (result["alertStyle"] == constants.NOTIFICATION_ALERT_STYLE_ALERT) {
alert("alertStyle:NOTIFICATION_ALERT_STYLE_ALERT");
}
}
Input Parameters
None
Return Values
The result Array consists of AuthorizationStatus, NotificatinCenterSetting, AlertSetting, BadgeSetting, LockScreenSetting, SoundSetting, AlertStyle.
Constants
- NOTIFICATION_AUTHORIZATION_STATUS_AUTHORIZED: App has notification support and it is enabled.
- NOTIFICATION_AUTHORIZATION_STATUS_DENIED: App has notification support, but notification is disabled under the settings.
- NOTIFICATION_AUTHORIZATION_STATUS_NOT_DETERMINED: App doesn’t support notifications.
- NOTIFICATION_SETTING_ENABLED: Alert/Badge/LockScreen/NotificationCenter/Sound setting enabled for the notification.
- NOTIFICATION_SETTING_DISABLED: Alert/Badge/LockScreen/NotificationCenter/Sound setting Disabled for the notification.
- NOTIFICATION_SETTING_NOT_SUPPORTED: Alert/Badge/LockScreen/NotificationCenter/Sound setting not supported.
- NOTIFICATION_ALERT_STYLE_NONE: Notification alert style set to none.
- NOTIFICATION_ALERT_STYLE_BANNER: Notification alert style set to banner.
- NOTIFICATION_ALERT_STYLE_ALERT: Notification alert style set to alert.
Platform Availability
- iOS
This API enables you to get the application mode.
Syntax
kony.application.getApplicationMode();
Example
function getApplicationMode() {
kony.application.getApplicationMode();
}
Input Parameters
None
Return Values
Integer Constant
- 1: constants.APPLICATION_MODE_NATIVE
- 2: constants.APPLICATION_MODE_HYBRID
- 3: constants.APPLICATION_MODE_WRAPPER
Special Considerations
This API should be called only in preappinit or before the execution of preappinit. If this API is invoked elsewhere in the program, it is invalid and leads to undefined behavior.
Exceptions
Error
Platform Availability
Available on all platforms.
iOS prohibits UI updates when the app is running in the background. Using this API you can check whether the app is running in the background or not to make UI updates. The possible application states are active, inactive, or background.
Syntax
kony.application.getApplicationState();
Example
//Sample code to get the application state
function util() { var appState = kony.application.getApplicationState(); if (appState = constants.APPLICATION_STATE_BACKGROUND) { kony.print(appState); } }
Input Parameters
None
Return Values
This API returns the following constant values:
- APPLICATION_STATE_ACTIVE
- APPLICATION_STATE_INACTIVE
- APPLICATION_STATE_BACKGROUND
Platform Availability
- iOS
This API enables you to read the badge value (if any) attached to the specified app menu item. If the specified app menu item does not have any badge value attached to it, the API returns an empty string.
Syntax
kony.application.getAppMenuBadgeValue(appmenuID, menuItemID);
Input Parameters
| Parameter | Description |
|---|---|
| appMenuId [String] - Mandatory |
If you are setting the badge for an app menu item that was created dynamically, use the same ID that was used to create the app menu item.If you are setting the badge for an app menu item that was created from the IDE, use the ID available in the generated script file. |
| menuItemId [String] - Mandatory | Identifier of the app menu item from which the badge value is to be read. |
Example
onClickMenuItem1: function() {
alert("The Badge Value of Accounts App Menu Item is " + kony.application.getAppMenuBadgeValue("SampleAppMenu", "appmenuitemid1"));
},
onClickMenuItem2: function() {
alert("The Badge Value of Examination App Menu Item is " + kony.application.getAppMenuBadgeValue("SampleAppMenu", "appmenuitemid2"));
},Return Values
| Return Value | Description |
|---|---|
| badgeValue [String] | Returns the badge value applied to the specified app menu. If the specified app menu has no badge value attached to it, it returns an empty string. |
Platform Availability
- iOS
This API retrieves the list of parameters attached to a URL using the above add, set APIs.
Syntax
kony.application.getBMState(formID);
Input Parameters
| Parameter | Description |
|---|---|
| formID [String] - Mandatory. | Identifier of the form for which the parameters of the URL have to be fetched. |
Example
getbookmark: function() {
var a = kony.application.getBMState("Form1");
alert(" The list of parameters attached to the URL are " + JSON.stringify(a));
},Return Values
A JSON structure representing key-values of various parameters attached to the URL string of the given form.
Platform Availability
- Desktop Web
This API returns the current breakpoint value.
Syntax
kony.application.getCurrentBreakpoint();
Input Parameters
None
Return Values
This API returns the current breakpoint
If window size exceeds the highest of breakpoints list, returns constants.BREAKPOINT_MAX_VALUE.
Platform Availability
- Desktop web
This API returns a handle to the current form. The form handle is useful when you are sending analytics to the analytic engine.
NOTE: For iOS, kony.application.getCurrentForm() returns the form id of current form. This rule does not apply for form used as cameraOverlay.
Use Case
You can use this API in the following scenarios:
- When you want to send analytics to the analytic engine.
- When you want to use the handle to the current form in any other function.
Syntax
kony.application.getCurrentForm();
Example
function getCurrentForm() {
//Get the current form
var currentForm = kony.application.getCurrentForm();
//Alert the current form
alert("currentForm is::" + currentForm);
}
Input Parameters
None
Return Values
currentForm - Object
This API returns the current form.
Rules and Restrictions
The following are the guidelines applicable for the API:
- If you invoke this API in the
preshowmethod of the application, it does not have any affect. - If you invoke this API in the
appinitmethod of the application, nil is returned.
UI Behavior
None
Platform Availability
Available on all platforms.
This API returns the package name from which the application was installed. Therefore, identifying the market that the application was downloaded from. It is important to know the source of installation of the application for security purposes.
Syntax
kony.application.getInstallerSourceInfo();
Input Parameters
None
Example
var devInfo = kony.os.deviceInfo();
var installSourceInfoDetails = kony.application.getInstallerSourceInfo();
if(devInfo.APILevel >= 30){
var originatingPackageName = installSourceInfoDetails.originatingPackageName;
var initiatingPackageName = installSourceInfoDetails.initiatingPackageName;
var installingPackageName = installSourceInfoDetails.installingPackageName;
alert("originatingPackageName: "+originatingPackageName +
"initiatingPackageName: "+initiatingPackageName +
"installingPackageName: "+installingPackageName);
} else { var installerPackageName = installSourceInfoDetails.installerPackageName; alert("installerPackageName: "+installerPackageName);
}
Return Values
This API returns a JS Object based on the Target SDK version of the device.
If the device uses TargerSDK versions 30 and above, the API returns the following values:
| Return Value | Description |
|---|---|
| initiatingPackageName |
The name of the package that requested the installation. The parameter returns a blank string if the initiating package name is not available. |
| installingPackageName |
The name of the package responsible for the installation (the installer of record), The parameter returns a blank string if the installing package name is not available. |
| originatingPackageName |
The name of the package on behalf of which the initiating package requested the installation. The parameter returns a blank string if the originating package name is not available. |
If the device uses TargerSDK versions 29 or earlier, the API returns the following values:
| Return Value | Description |
|---|---|
| installerPackageName | The name of the package that has installed the application. |
Platform Availability
Android
This API returns a handle to the previous form.
Use Case
You can use this API in the following scenarios:
- When you want to send analytics to the analytic engine.
- When you want to use the handle to the current form in any other function.
Syntax
kony.application.getPreviousForm();
Example
function getPreviousForm() {
//Get the Previous form
var previousForm = kony.application.getPreviousForm();
//Alert the Previous form
alert("previousForm is::" + previousForm);
}
Input Parameters
None
Return Values
| Return Value | Description |
|---|---|
| previousForm-Object |
API returns the previous form handle. |
Rules and Restrictions
The following are the guidelines applicable for the API:
- If you invoke this API in
preshowevent of the application, you get unpredictable results. - If you invoke this API in the
appinitmethod of the application, nil is returned.
- If you use this API on the first form of the application it returns null/nil.
UI Behavior
None
Platform Availability
Available on all platforms.
You can use this API to retrieve the current device setting. You must pass the setting that you want to query, in the input parameter of this API.
Syntax
kony.application.getSettingValue(setting, args);
Parameters
setting[String]- Mandatory
The setting to be queried must be passed in this parameter. Following are the settings supported by various platforms:
- Android: "location", "device_locale", "time_zone", and "wifi".
| Settings | Description |
|---|---|
| location |
This key is used to identify the current "location" status of the device. Calling the kony.application.getSettingValue API with this key returns a JavaScript object, which has the following key values:
|
| device_locale |
This key is used to identify the current device locale of the device. Calling the kony.application.getSettingValue API with this key returns a JavaScript object, which has the following key value:
|
| time_zone |
This key is used to identify the current device time zone of the device. Calling the kony.application.getSettingValue API with this key returns a JS object, which has the following key value:
|
| wifi |
This key is used to identify the current wifi state of the device. NOTE: To query this setting, you must add the following permission to the AndroidManifest.xml file: Calling the kony.application.getSettingValue API with this key returns a JS object, which has the following key values:
The list of wifi states is as follows:
|
| Settings | Description |
|---|---|
| applicationAppearanceStyle |
iOS 13 provides support for dark mode in iOS devices. This key enables you to identify the appearance mode of iOS devices. When the kony.application.getSettingValue API is called with this key, any of the following values are returned:
This is applicable from Quantum VisualizerV8 SP3 FP 58 and Quantum VisualizerV8 SP4 FP 45. NOTE: By default, the dark and light modes are supported for apps that are built on iOS 13 devices. |
alert(kony.application.getSettingValue("location"));
Example 2:
var args = [kony.SystemColorType.Background];
alert(kony.application.getSettingValue("color", args));
Example 3:
function getAppearenceStyle() {
var themeApearenceStyle =
kony.application.getSettingValue("applicationAppearanceStyle");
switch (themeApearenceStyle) {
case kony.application.APPEARANCESTYLE_DARK:
alert("APPEARENCE STYLE : dark mode");
break;
case kony.application.APPEARANCESTYLE_LIGHT:
alert("APPEARENCE STYLE : light mode");
break;
case kony.application.APPEARANCESTYLE_UNKNOWN:
alert("APPEARENCE STYLE : unknown mode");
break;
}
}
function callback(params) {
switch (params.setting) {
case "applicationAppearanceStyle":
switch (params.applicationAppearanceStyle) {
case kony.application.APPEARANCESTYLE_DARK:
//alert("selected dark mode");
kony.theme.setCurrentTheme("darkTheme",
onThemeCallback, onThemeCallback);
break;
case kony.application.APPEARANCESTYLE_LIGHT:
//alert("selected light mode");
kony.theme.setCurrentTheme("lightTheme",
onThemeCallback, onThemeCallback);
break;
case kony.application.APPEARANCESTYLE_UNKNOWN:
//alert("selected unknown mode");
break;
}
break;
}
function onThemeCallback() {
//alert("theme callback");
}
}
kony.application.registerOnSettingsChangeCallback(["applicationAppearanceSty
le"], callback);
Platform Availability
- Android
- iOS
This API checks whether the current application is present in the power white-list of the device.
You can request the user to add or remove the app from the power white-list of the device by using the kony.application.launchBatteryOptimizationSettings API.
Syntax
kony.application.isIgnoringBatteryOptimizations();
Input Parameters
None
Example
function isIgnoringBatteryOptimizations() {
var retVal = kony.application.isIgnoringBatteryOptimizations();
kony.print(" Is my application ignoring Battery Optimizations "+ retVal);
}
Return Values
Boolean.
Remarks
The kony.application.isIgnoringBatteryOptimizations API is only supported on Android devices with OS API level 23, and later. When this API is invoked on Android devices with OS API level 22 (and earlier), the API always returns the value true.
Ensure that you set the value of the enableBatteryOptimizationAPI property to true in the androidbuild.properties file to enable this API.
Platform Availability
Android
This API is used to get the status of image settings, which are defined by a particular user, in a web browser.
Syntax
kony.application.isImageTurnedOff(imageCb);
Input Parameters
| Parameter | Description |
|---|---|
| imageCb |
The kony.application.isImageTurnedOff API takes the imageCb function as an argument, and returns either true or false based on the browser settings for images. |
Example
function getImageStatus() {
kony.application.isImageTurnedOff(imageCb);
}
function imageCb(param) {
if (param === true) {
DesktopApis.lbl1.text = "Image settings in web browser is disabled";
} else {
DesktopApis.lbl1.text = "Image settings in web browser is enabled";
}
DesktopApis.forceLayout();
}
Return Values
- true: If the user disables the display of images from the browser settings, the kony.application.isImageTurnedOff API returns true.
- false: If the user enables the display of images in the browser, the kony.application.isImageTurnedOff API returns false.
Platform Availability
- Desktop Web
Returns true if the application is in multi-window mode, and the function returns false if the application is in full-screen mode.
Syntax
kony.application.isInMultiWindowMode();
Example
function checkMultiWindowMode() {
var isInMultiWindow = kony.application.isInMultiWindowMode();
kony.print("Multi Window Mode : " + isInMultiWindow);
}
Input Parameters
None.
Return Values
Boolean value.
Platform Availability
- Android 7.0 and later
This API is used to get the status of pop-up settings, which are defined by a particular user, in a web browser.
Syntax
kony.application.isPopupBlocked(popupCb);
Input Parameters
| Parameter | Description |
|---|---|
| popupCb |
The kony.application.isPopupBlocked API takes the popupCb function as an argument, and returns either true or false based on the browser settings for pop-ups. |
Example
function getPopupStatus() {
kony.application.isPopupBlocked(popupCb);
}
function popupCb(param) {
if (param === true) {
Form1.lbl1.text = "Pop-up blocker is enabled. Please do not allow pop-ups from this website.";
} else {
Form1.lbl1.text = "Popup blocker is turned off.";
}
Form1.forceLayout();
}
Return Values
| Return Value | Description |
|---|---|
| true | If the user disables the display of pop-ups from the browser settings, the kony.application.isPopupBlocked API returns true. |
| false |
If the user enables the display of pop-ups in the browser, the kony.application.isPopupBlocked API returns false. |
Platform Availability
- Desktop Web
This API opens the settings screen of the device that displays options to control the battery optimization behavior of the app.
By using the kony.application.launchBatteryOptimizationSettings API, users can be directed to add or remove the app from the power white-list of the device by following these steps:
- Select the current app from the list displayed on the settings screen.
- Select Optimize to turn on battery optimization for the app.
Similarly, select Don't Optimize to turn off battery optimization for the app.
NOTE: The steps to add an app to the power white-list of a device may vary depending on the device being used.
- Before you invoke the kony.application.launchBatteryOptimizationSettings API, invoke the kony.application.isIgnoringBatteryOptimizations to determine if an application is already ignoring optimizations.
- Alternatively, you can also use the kony.application.requestIgnoreBatteryOptimizations API to request the user to add the app to the power white-list of the device without navigating to the settings page.
Syntax
kony.application.launchBatteryOptimizationSettings(callback);
Input Parameters
| Parameter | Description |
|---|---|
| callback - Optional | The callback function to be executed when the user navigates back to the application from the settings screen. |
Example
function launchBatteryOptimizationSettings() {
kony.application.launchBatteryOptimizationSettings(settingsCallback);
},
function settingsCallback()
{
//You can Call kony.application.isIgnoringBatteryOptimizations() to determine whether the application is ignoring battery optimizations.
}Return Values
None
Remarks
- The kony.application.launchBatteryOptimizationSettings API is only supported on Android devices with OS API level 23, and later.
- Ensure that you set the value of the
enableBatteryOptimizationAPIproperty to true in theandroidbuild.propertiesfile to enable this API. - If you invoke the kony.application.launchBatteryOptimizationSettings API when the application is running in the background, the settings screen may not launch.
Platform Availability
Android
Opens the application-specific settings or device-level application settings.
You may need to direct the end-user to application settings to manually enable or disable a permission for the app to access a particular resource. This function is required when the end-user had denied the permission when the app prompted with a dialog box, and later wants the app to access the resource. For example, if your app wants to access the user's contacts - so the app displayed a dialog box with "Allow" and "Deny" options, asking end-user to grant permission for the first time. The end-user tapped the "Deny" option and the app cannot access the user's contacts. Later, after some point of time, if end-user wants the app access the user's contacts; at that time, you can call the openApplicationSettings API that allows the user to navigate to the application settings screen, and then grant the required permission to the app.
The behavior of the openApplicationSettings API in different platforms:
- iOS: Opens the application-level settings screen showing the access status of the resource. The end-user can turn on or off the access to the resource from the app. The resourceid parameter is ignored in the iOS platform.
- Android: Opens the application-level settings screen showing the access status of the resource. The end-user can turn on or off the access to the resource from the app. The resourceid parameter is ignored in the iOS platform.
Syntax
kony.application.openApplicationSettings();
Example
kony.application.openApplicationSettings(kony.os.RESOURCE_CONTACTS);
Return Values
None
Platform Availability
- Android
- iOS
This API launches the native media player and starts playing the media (audio or video) at the specified URL. The media server provides the appropriate media content depending upon the device (for example, iPhone, etc).
Use Case
You can use this API when you want to access and use multimedia from an external URL or server.
Syntax
kony.application.openMediaURL(URL);
Input Parameters
| Parameter | Description |
|---|---|
| URL [String] - Mandatory |
Specifies the URL that points to the audio/video file |
Example
function openMediaURL() {
/*Launching the native media player and starts playing the media(audio or video) at the URL:"http://www.boisestatefootball.com/sites/default/files/videos/original/01%20-%20coach%20pete%20bio_4.mp4" */
kony.application.openMediaURL("http://www.boisestatefootball.com/sites/default/files/videos/original/01%20-%20coach%20pete%20bio_4.mp4");
}
Return Values
None
Implementation Details
This API assumes that the media is available at the specified URL. The API does not check for the availability of the media at the specified location. The responsibility lies on the developer to ensure that appropriate media is available at the referred URL.
Any errors related to the type of media or the availability of the media are handled by the native media player. The errors are not propagated back to the application.
NOTE: For more information on media formats, see:
Android: http://developer.android.com/guide/appendix/media-formats.html. You have to provide an absolute path of the video file in the URL. For example, http://www.boisestatefootball.com/sites/default/files/videos/original/01%20-%20coach%20pete%20bio_4.mp4 or the URL should be in 'rtsp' format if it is a YouTube video.
iPhone: Apple Documentation
Platform Availability
Available on all platforms.
This API opens the specified settings screen.
Syntax
kony.application.openSettings(config);
Input Parameters
config - A JSON Object that contains the following keys:
| Key | Description |
|---|---|
| intentAction [String] |
A String that specifies the desired settings screen. The intentAction parameter can have the following values:
The default value of this parameter is ACTION_SETTINGS. NOTE: If the intentAction is set as ACTION_APPLICATION_DETAILS_SETTINGS, the API does not return a callback. |
| statusCallback [Function] |
A callback function that specifies the launch status of the settings screen. The callback function is a JSON Object that contains the following keys:
|
Example
callOpenSettingsAPI : function(){
var config={
"intentAction": "ACTION_SECURITY_SETTINGS",
"statusCallback": this.myCallback
}
kony.application.openSettings(config);
},
myCallback : function(info){
alert("Callback1 invoked! info.statusCode = "+ info.statusCode);
}Return Values
None
| Constant | Description |
|---|---|
| SETTINGS_LAUNCH_SUCCESSFUL | The constant that is returned when the settings screen is successfully launched. |
| SETTINGS_LAUNCH_FAILED | The constant that is returned when the settings screen launch fails. |
| USER_RETURNED_FROM_SETTINGS | The constant that is returned when the user returns from the launched settings screen. |
| API_NOT_SUPPORTED_IN_BACKGROUND | The constant that is returned if the API is invoked when the app is running in the background. |
Platform Availability
- Android
This API opens the web page at the specified URL in the native browser of the mobile device.
Use Case
You can use this API when you want to access an external web page within the application. With this API, you can open a web page without using a browser widget in your application.
Syntax
kony.application.openURL(URL);
Input Parameters
| Parameter | Description |
|---|---|
| URL [String] - Mandatory |
Specifies the URL that points to the external web page |
Example
//The following function is for openURL API
function openURL() {
//Accessing an external web page : http://www.google.com
kony.application.openURL("http://www.google.com");
}
Return Values
None
Implementation Details
When you use this API, the behavior of the application is as follows on different platforms:
| Platform | Behavior |
|---|---|
| iPhone |
NOTE: Support for the openURL API has been deprecated for the iPhone platform. To achieve the functionality of the kony.application.openURL API in Quantum Visualizer V9, use the kony.application.openURLAsync API. |
| Android | The application opens the specified URL in the native browser and the application goes into background |
Platform Availability
- Android
NOTE: Support for the openURL API has been deprecated for the iPhone platform.
This API opens the web page at the specified URL in the native browser of the mobile device. The openURLAsync API is the asynchronous counterpart of the kony.application.openURL API.
Use Case
You can use this API when you want to asynchronously access an external web page within the application. With this API, you can open a web page without using a Browser widget in your application.
Syntax
kony.application.openURLAsync(CONFIG);
Input Parameters
| Parameter | Description |
|---|---|
| CONFIG[JSObject] - Mandatory |
This is the parent encapsulating object that stores these configuration keys: url and callback. Configuration Keys
|
Example
var _url = "fb://page/" + FB_PAGE_ID;
var callbackFunction = function(response) {
if (response == constants.OPEN_URL_SUCCESS) {
//openURL return successfull from Native Side
} else if (response == constants.OPEN_URL_FAILURE) {
//openURL return failed from Native Side
} else if (response == constants.OPEN_URL_UNKNOWN) {
// if native don't provide a callback, we need to supply this to the end user
}
};
kony.application.openURLAsync({
url: _url,
callback: callbackFunction
});
Response Type for the Callback Function
constants.OPEN_URL_SUCCESS constants.OPEN_URL_FAILURE constants.OPEN_URL_UNKNOWN /*If the native platform does not provide any callback, this constant will be passed in the callback by default.*/
Return Values
None
Native Limitations
- Because of the asynchronous nature of the openURLAsync API, some cross-platform inconsistency may occur.
Platform Availability
- Android
- iOS
This API posts a notification to "assistive" applications, i.e., applications that are designed to increase accessibility for blind and low-vision users, as well as for users with dyslexia.
Your application may need to post accessibility notifications if you have user interface (UI) components that change very frequently or ones that appear and disappear. Examples of such UI components include widgets that can be hidden or made visible in the layout on the click of a button.
Every Quantum Visualizer Widget contains the VoiceOver accessibility feature, i.e., a voice-over that reads the titles of Quantum Visualizer Widgets once a notification is posted.
Accessibility is directly managed by native iOS, and users don't have the control to set the focus, especially in Browser widgets. As a result, whenever a screen changes, the accessibility control sometimes remains in the previous screen. So, in order to set the focus of accessibility to the new screen, this API is used to notify the operating system that the screen has changed.
Syntax
kony.application.postAccessibilityNotification(config);
Input Parameters
| Parameter | Description |
|---|---|
| config - Mandatory |
This is a jsdict. config[jsdictionary] accessibilityNotificationName[const] - Mandatory Here, the constant (const) specifies the type of notification that the app can send. constants.ACCESSIBILITY_SCREENCHANGED_NOTIFICATION This is posted by the app when a new view appears that takes up a major portion of the screen. |
Example
kony.application.postAccessibilityNotification({
accessibilityNotificationName:constants.ACCESSIBILITY_SCREENCHANGED_NOTIFICATION});
Return Values
None
Platform Availability
- iOS
Recommends an App Store Application on iOS devices. When you invoke this API, the system displays an overlay that showcases information about the App Store Application.
Syntax
kony.application.recommendApp(appConfig);
Input Parameters
appConfig: A JavaScript object that contains the following key-value pairs:
| Parameter | Description |
|---|---|
| appIdentifier [String/Constant]- Mandatory |
The iTunes Identifier of the App Store Application that must be displayed as an overlay. |
| position [Constant]- Optional |
A constant that identifies the position of the overlay on the screen. Following is a list of supported constants:
The default value for the position key is kony.application.STORE_OVERLAY_POSITION_BOTTOM. |
Example
var appConfig = {
"appIdentifier": <iTunes Identifier>,
"position": <position options>
};
kony.application.recommendApp(appConfig);
Return Values
None.
Remarks
- While using App Clips, to recommend the parent application, provide the
kony.application.PARENT_APP_IDENTIFIERvalue for theappIdentifierkey in the appConfig as follows:kony.application.recommendApp( { "appIdentifier" : kony.application.PARENT_APP_IDENTIFIER } )
- To capture error or overlay events during the App Recommendation, you must invoke the kony.application.setApplicationCallbacks API with a callback for the storeoverlayevent as follows:
kony.application.setApplicationCallbacks({ "storeoverlayevent": <JS Function>})
The following values are supported for the App Recommendation Event States:
- kony.application.STORE_OVERLAY_STATE_WILL_START_PRESENTATION
- kony.application.STORE_OVERLAY_STATE_DID_FINISH_PRESENTATION
- kony.application.STORE_OVERLAY_STATE_WILL_START_DISMISSAL
- kony.application.STORE_OVERLAY_STATE_DID_FINISH_DISMISSAL
- kony.application.STORE_OVERLAY_STATE_LOAD_ERROR
Here is a sample implementation of the kony.application.setApplicationCallbacks invoked with the storeoverlayevent .
addListenerForStoreOverlayEvent: function() {
kony.application.setApplicationCallbacks({
"storeoverlayevent": this.storeoverlaycallback
});
alert("Listener added for Store Overlay Event !!!");
}
storeoverlaycallback: function(eventInfo) {
alert("[ storeoverlaycallback ] EventInfo : " + JSON.stringify(eventInfo));
switch (eventInfo.state) {
case kony.application.STORE_OVERLAY_STATE_WILL_START_PRESENTATION:
alert("[ storeoverlaycallback ] : Will Start Presentation !!!");
break;
case kony.application.STORE_OVERLAY_STATE_DID_FINISH_PRESENTATION:
alert("[ storeoverlaycallback ] : Did Finish Presentation !!!");
break;
case kony.application.STORE_OVERLAY_STATE_WILL_START_DISMISSAL:
alert("[ storeoverlaycallback ] : Will Start Dismissal !!!");
break;
case kony.application.STORE_OVERLAY_STATE_DID_FINISH_DISMISSAL:
alert("[ storeoverlaycallback ] : Did Finish Dismissal !!!");
break;
case kony.application.STORE_OVERLAY_STATE_LOAD_ERROR:
alert("[ storeoverlaycallback ] : Load Error !!!");
break;
}
}
Platform Availability
iOS
This API specifies if the application must timeout after a defined period of inactivity (time difference between the current device time and the last time you clicked on any user interface component) and also specifies the action after the timeout interval.
IMPORTANT: You must enable the forms for idletimeout by setting the property for enabledForIdleTimeout as True in the IDE. The idletimeout event is triggered only when the user is on a form that is enabled for idletimeout.
When the idletimeout event is triggered, the user is navigated to the home screen with an alert message.
In BJS devices, to validate registerForIdleTimeout, an event must be triggered once time out is occurred.
Use Case
You can use this API typically in financial applications when you want to log the user out automatically after a specific period of inactivity. This way, you can ensure that there is no un-authorized access to the application or to the sensitive information like account number, credit card numbers, and so on.
Syntax
kony.application.registerForIdleTimeout(timeoutValue, callback)
Input Parameters
| Parameter | Description |
|---|---|
| timeoutValue [Number] - Mandatory |
The timeout value in minutes. |
| callback [Function] - Mandatory | The function that must be executed after the timeout has occurred. The callback function has the logic to display the current form. The function can be changed during runtime. |
NOTE: Current form is the Form that was being displayed on the device screen when the timeout occurred.
Example
function test() {
//Logic for the callback function registerForIdleTimeout
}
function registerForIdleTimeout() {
kony.application.registerForIdleTimeout(1, test);
}Return Values
None
Implementation Details
The idletimeout event is triggered only once for every call to registerForIdleTimeout API and this event is not fired again until the next call to the API. The idletimeout event unregisters itself automatically when the event is fired. When the event unregisters itself, the application can register again for idletimeout.
The following are a few scenarios:
Scenario 1
idletimeout event is triggered after the specified time interval, but the user is on a form that is not enabled for idletimeout. In this case, the function associated with the event is executed as soon as the user navigates to the form that is enabled for idletimeout.
NOTE: In this case, the form that the user is trying to navigate to is never shown as the idletimeout event takes precedence.
Scenario 2
idletimeout event is triggered and the user is on a form enabled for idletimeout. In this case, the associated function is executed immediately.
Scenario 3
The application is registered for idle time out and the user tries to register again for idletimeout. In this case, the latter call to the registerForIdleTimeout API has no affect and is ignored.
Scenario 4
The application is registered for idletimeout but none of the forms in the application are enabled for idletimeout. In this case, this API has no affect and the behavior of the application is undefined.
Each underlying platform handles the idletimeout event differently:
iPhone
- When the application is running in the background, no logic is executed. However, the timers keep running and the idletimeout event is triggered in the background. But the function is executed immediately when the application comes to foreground.
NOTE: When the application comes to foreground, you will suddenly notice the function of the idletimeout event getting executed.
Android
- When you press the device Back button to go out of the application, the underlying OS destroys the UI activity. In such cases, the idletimeout event is fired only when the application comes to the foreground.
- When you navigate out of the application using the device Home button, the underlying OS pauses the UI activity but does not destroy it. In such cases, the idletimeout event is fired immediately in the background.
Rules and Restrictions
This API is applicable only when the Form property Enable Time Out is set to true. For more information about Enable Time Out property, see Quantum VisualizerWidget User Guide.
Exceptions
An error is thrown if input is invalid or does not follow the expected structure.
102-Invalid input error
Platform Availability
Available on all platforms.
Customers can use the registerOnSettingsChangeCallback API to listen in Quantum applications, if any settings have been changed in Native settings applications. Users can pass the list of required settings in the first parameter. In addition, users can pass the callback, which is invoked when any required setting is changed, in the second parameter. The callback is invoked with parameters, which provide information about the setting that was changed and the values of said setting. If users want to stop listening to changes in the settings, they must successfully register and pass null in the second parameter as well as pass the list of settings that they want to stop listening in the first parameter.
Syntax
kony.application.registerOnSettingsChangeCallback(settingsList,callback);
Input Parameters
settingsList[JSONObject]- Mandatory
The list of settings that users want to listen must be provided in this parameter. It can have one or more values. Following are the settings supported by various platforms:
- Android: "location", "device_locale", "time_zone", "time", and "wifi".
callback[Function object] - Mandatory
The callback to be invoked when there is a change in any setting that is passed in the first parameter. This callback must be passed in the second parameter. This is the single function for all the settings. It can have function object or null value. Function object is passed for listening to settings and null value is passed to stop listening to setting changes. If any registered setting changes, the callback is invoked with JS object. This object contains information about the changed setting. Depending on the setting that is changed, the JS object can have different keys. Following are the various keys that JS object can contain:
- Android
| Settings | Description |
|---|---|
| location |
|
| device_locale |
|
| time_zone |
|
| time |
|
| wifi |
If the "wifi" setting changes, the JS object passed to the callback has the following key values:
The list of wifi states is as follows:
NOTE: If you invoke the registerOnSettingsChangeCallback API with "wifi" setting, the callback is invoked immediately with setting key as "wifi". This occurs because of native behavior. |
Example
function callback(params) {
switch (params.setting) {
case "location":
alert(params.gps_provider);
alert(params.network_provider);
break;
case "device_locale":
alert(params.device_locale);
break;
case "time_zone":
alert(params.time_zone);
break;
case "time":
alert("time is changed in settings");
break;
case "wifi":
alert(params.wifi_current_state);
alert(params.wifi_previous_state);
break;
}
}
//To register for setting changes.
kony.application.registerOnSettingsChangeCallback(["location", "device_locale", "time_zone", "time", "wifi"], callback);
//To deregister for setting changes.
kony.application.registerOnSettingsChangeCallback(["location", "device_locale", "time_zone", "time", "wifi"], null);
//To register for setting changes.
kony.application.registerOnSettingsChangeCallback(["location"], callback);
//To register for setting changes.
kony.application.registerOnSettingsChangeCallback(["device_locale", "time_zone"], callback);
Platform Availability
- Android
The kony.application.removeApplicationCallbacks API helps you to clear callback functions associated with the specified appstates. This API is available from V8 SP4 onwards.
Syntax
kony.application.removeApplicationCallbacks(appstatesMap);
Input Parameters
appstatesMap [Object] - Mandatory
Specifies an Object with key as appstate and value as an array of function IDs for the corresponding appstate for which the registered callback functions need to be cleared. The following appstates are applicable:
| App state | Description |
|---|---|
| isAppLaunchedForInteraction |
State which indicates that the application is visible to users for interaction. |
| onactive | State which indicates that the mobile device is active and the application is running. |
| oninactive | State which indicates that the mobile device is inactive and the application is running. |
| onbackground | State which indicates that the application is active and running in the background. |
| onforeground | State which indicates that the application is active and running in the foreground. |
| onappterminate | State which indicates that the application has been terminated, and has stopped running. |
| onkeyboardchange | State which indicates whether a keyboard is deployed for an application. |
| onpowersourcechange | State which indicates whether a power source is attached to the user's device. |
| onnetworkchange |
This is specific to Mango. State which occurs when there is a change in the following:
|
Example
var callbacksToBeRemoved = {
"isAppLaunchedForInteraction": ["functionID1", "functionID2"]
};
kony.application.removeApplicationCallbacks(callbacksToBeRemoved);
Platform Availability
- Android
- iOS
This API removes a specified key from the parameter list of the URL of the form.
Syntax
kony.application.removeBMState(formID, key);
Input Parameters
| Parameter | Description |
|---|---|
| formID [String] - Mandatory. | Identifier of the form for which the parameters of the URL have to be removed. |
| key [String] - Mandatory | Key string representing the key to be removed. |
Example
To remove a bookmark for a URL, enter the following:
removebookmark: function() {
kony.application.removeBMState("Form1", "About");
alert("The About key is removed from the parameter list");
},Return Values
None
Platform Availability
- Desktop Web
This method allows you to remove a specified gesture recognizer for all Forms.
Syntax
kony.application.removeGestureRecognizerForAllForms(uniqueIdentifier);
Input Parameters
| Function | Description |
|---|---|
| uniqueIdentifier - Mandatory | Reference to the gesture. The reference to the gesture is returned by the setGestureRecognizerForAllForms. |
Example
function callbackClearLongPressGesture() {
try {
kony.application.removeGestureRecognizerForAllForms(uniqueidentifier);
} catch (err) {
alert(typeof err);
alert("error in function callbackClearLongPressGesture: " + err.message);
}
}Platform Availability
Available on all platforms except Desktop Web.
Clears the flag that caches forms for SEO.
Syntax
kony.application.removeSeoDataReadyFlag();
Example
kony.application.removeSeoDataReadyFlag();
Input Parameters
None.
Return Values
None.
Remarks
For information on SEO, see kony.application.setSeoDataReadyFlag and the Quantum VisualizerUser Guide.
This API displays a dialog box with the ALLOW and DENY options to control the battery optimization state for an app, without having to open the device settings.
If the user selects the ALLOW option, the app is added to the power white-list of the device.
If the user selects the DENY option (or taps the back arrow in the dialog box), the app is not added to the power white-list of the device, and the white-list status of the app does not change.
- Before you invoke the kony.application.requestIgnoreBatteryOptimizationsAPI, invoke the kony.application.isIgnoringBatteryOptimizations to determine if an application is already ignoring battery optimizations.
- Ensure that you add the REQUEST_IGNORE_BATTERY_OPTIMIZATIONS permission in the Android Manifest file of the project.
- Most applications must not use battery optimizations as the platform provides various facilities for applications to operate as expected in different power-saving modes. You must only use this API in specific applications that need to complete control for execution, at the potential expense of the device's battery life. These applications might display the high power usage notification to the users.
When you use the REQUEST_IGNORE_BATTERY_OPTIMIZATIONS permission without a proper use-case or a usage justification, the Google Play Store may reject the application upload.
Here are a few real-time use-cases that may need exclusion from power optimization to avoid problems in Doze mode:
- Data synchronization apps such as Google Photos (that back up photos to the cloud), Field Services applications (that need the latest data to be synchronized with the server).
Battery optimization in these apps may cause delays in sync and loss of data from the device in case the device is damaged or lost. - Real-time message communication apps such as WhatsApp, Telegram, SMS, etc.
Battery optimization in these apps may cause a delay in receiving message notifications. - VPN apps.
Battery optimization in these apps may cause VPNs to drop the connection when the display of the phone is off. - Time-sensitive apps such as SMS schedulers.
Battery optimization in these apps may result in a failure to send the scheduled messages on time.
Syntax
kony.application.requestIgnoreBatteryOptimizations(callback)
Input Parameters
| Parameter | Description |
|---|---|
| callback - Optional |
The callback function to be invoked when the user selects the ‘ALLOW’ or 'DENY' option in the dialog box. The signature of the callback function is callback(code), where code is a Battery Optimization Response Code. |
Example
function requestIgnoreBatteryOptimizations() {
kony.application.requestIgnoreBatteryOptimizations(dialogActionCallback);
},
function dialogActionCallback(code)
{
if(code == kony.application.IGNORE_BATTERY_OPTIMIZATIONS_ACCEPTED)
{
//This code indicates that the user has pressed Allow on the Ignore Battery optimiation dialog.
}
else if(code == kony.application.IGNORE_BATTERY_OPTIMIZATIONS_REQUEST_CANCELLED)
{
//This code indicates that the user has denied the Ignore Battery optimiation dialog.This response code may sent to callback even when your application is already ignoring battery optimizations.
}
}
Return Values
None
Remarks
- The kony.application.requestIgnoreBatteryOptimizations API is only supported on Android devices with OS API level 23, and later.
- Ensure that you set the value of the
enableBatteryOptimizationAPIproperty to true in theandroidbuild.propertiesfile to enable this API. - The kony.application.requestIgnoreBatteryOptimizations API will not invoke a system dialog if an application is already ignoring battery optimizations.
- If you invoke the kony.application.isIgnoringBatteryOptimizations API when the application is running in the background, the dialog box may not be displayed on the device.
Battery Optimization Response Codes
| Code | Description |
|---|---|
| kony.application.IGNORE_BATTERY_OPTIMIZATIONS_ACCEPTED | Indicates that the user has selected Allow in the Ignore Battery optimization dialog box. |
| kony.application.IGNORE_BATTERY_OPTIMIZATIONS_REQUEST_CANCELLED | Indicates that the user has denied the Ignore Battery optimization in the dialog box.This response code may also be sent to the callback when the application is already ignoring battery optimizations. |
Platform Availability
Android
Sends a request to the end-user to provide the access to specific resource.
Syntax
kony.application.requestPermission(resourceId[constant/String], statusCallback[Function], options[JSObject]);
Input Parameters
Example 1
//< uses - permission android: name = "android.permission.READ_PHONE_STATE" >
kony.application.requestPermission("android.permission.READ_PHONE_STATE", permissionStatusCallback);
function permissionStatusCallback(response) {
if (response.status == kony.application.PERMISSION_GRANTED) {
kony.location.getCurrentPosition();
} else if (response.status == kony.application.PERMISSION_DENIED) {
//Display Application Settings alert by using kony.application.openApplicationSettings()
}
}
function requestpermission() {
var options = {
"isVideoCapture": true,
"getNeverAskAgainStatus": true
}
kony.application.requestPermission(kony.os.RESOURCE_LOCATION, permissionStatusCallback, options);
}
function permissionStatusCallback(response) {
alert("response ::" + JSON.stringify());
if (response.status == kony.application.PERMISSION_GRANTED) {
kony.location.getCurrentPosition();
} else if (response.status == kony.application.PERMISSION_DENIED) {
Requestpermission(); /* To show the reason to users for granting the permission to use the feature and then raise a request. */
} else if (response.status == kony.application.PERMISSION_NEVER_ASK_AGAIN) {
kony.application.openApplicationSettings(); /* To show the reason to users for granting the permission to use the feature and then open application settings to grant the request. */
}
)
}
Return Values
| Function | Description |
|---|---|
| JSObject |
A JSObject contains the authorization status of the requested resource. The returned JSObject contains the following key: status [constant] Resource status constant which indicates the overall status of the resource authorization. For more information, refer to Permission Status. NOTE: In the Android platform, the status remains PERMISSION_DENIED if at least one of the permissions associated with the resource is denied by the end-user. |
Platform Availability
- Android
- iOS
When invoked, this API sends a request for a set of permissions. The status of the request is sent back to the user through a callback.
Syntax
kony.application.requestPermissionSet(permissions, callback);
Input Parameters
| Parameter | Description |
|---|---|
| Permissions | Array of qualified android permission strings. |
| Callback | Function object result will invoke this function. The result is a JSobject where the key is permission string and the value is the permission status. |
Example
function requestpermission() {
kony.application.requestPermissionSet(["android.permission.CAMERA", "android.permission.WRITE_CONTACTS"], permissionStatusCallback);
}
function permissionStatusCallback(response) {
var camera = "android.permission.CAMERA";
var contacts = "android.permission.WRITE_CONTACTS";
for (var i in response) {
/* iterating through permissionSet key value pair from response jsObject where 'i' is permission key and result is permission status */
var result = response[i];
if (result == kony.application.PERMISSION_DENIED) {
// show message and raise request again
} else if (result == kony.application.PERMISSION_NEVER_ASK_AGAIN) {
// show message and open settings page
kony.application.openApplicationSettings();
}
}
}
Return Values
None.
Platform Availability
Android
This function requests users to provide a rating and to write a review for an app.
Syntax
kony.application.requestReview();
Input Parameters
None
Example
//To request the user for his rating on your app, use the below API
requestAppReview: function(){
kony.application.requestReview();
}
Return Values
None
IDE/ CodeGen Requirements
None
Platform Availability
- iOS
- Android
Error Codes
The Android error codes are as follows:
- Error code: 801
Message: Review Action Not Found
This error code is displayed if the requested Play Store or browser is not found. - Error code: 802
Message: Review Error Unknown
This API resets the state associated with the URL of a form. It removes all the parameters attached to the form URL
Syntax
kony.application.resetBMState(formID);
Input Parameters
| Parameter | Description |
|---|---|
| formID [String] - Mandatory. | Identifier of the form for which the parameters of the URL have to be removed. |
Example
resetBookmarkState: function() {
kony.application.resetBMState("Form1");
alert("The state is removed from the URL");
}Return Values
None
Platform Availability
- Desktop Web
This API allows you to send an acknowledgment to a Native app that launched this library. This API is available from V8 SP3 onwards.
For more information on Library mode, click here.
NOTE: Calling this API invokes the onLibraryResult() interface/protocol method, which is passed in the Native Start API of Quantum Visualizer Library.
Syntax
kony.application.sendLibraryResultToNativeApp(resultData);
Input Parameters
| Parameter | Description |
|---|---|
| resultData | An object with key-value pair elements with key as String and value as primitive data types (int, float, double, String, and Boolean). |
Example
var resultData = {
status: "success"
};
kony.application.sendLibraryResultToNativeApp(resultData);Return Values
None.
Platform Availability
- Android
- iOS
NOTE: The kony.application.sendLibraryResultToNativeApp API is only applicable when the app is launched in Library mode.
This API configures a container widget at the application level that can either be used as a header or a footer throughout the app.
Syntax
kony.application.setAppLevelWidget(object);
Input Parameters
object: A JavaScript object that contains the following key-value pairs:
| Key | Value |
|---|---|
| type [Integer] |
Specifies the type or position of the widget. The type key can have the following values:
The default value for the type key is kony.application.APP_LEVEL_FOOTER. |
| container [LuaWidget/ String] |
A JavaScript FlexContainer object that is to be displayed as the app level widget. You can provide a String value if you are using the MVC architecture. |
| appName [String] | The name of the app in the project. The appName is a mandatory parameter in case of inter-app template access. This is an optional parameter in case of intra-app template access. |
Example 1
//Sample code to set the Header:
kony.application.setAppLevelWidget({"type":kony.application.APP_LEVEL_HEADER,"container":FlexHeaderTemplate});
//Sample code to set the Footer:
kony.application.setAppLevelWidget({"type":kony.application.APP_LEVEL_FOOTER,"container":FlexFooterTemplate});
//Sample code for inter-app access:
var params = {"type": Constant, "container": "", "appName" : "" } kony.application.setAppLevelWidget(params);
Example 2 - MVC Project
//Sample code to set the Header:
kony.application.setAppLevelWidget({"type":kony.application.APP_LEVEL_HEADER,"container":”FlexHeaderTemplateString”});
//Sample code to set the Footer:
kony.application.setAppLevelWidget({"type":kony.application.APP_LEVEL_FOOTER,"container":”FlexFooterTemplateString”});
Return Values
This API may return the following values when invoked:
- 8000 - This constant is returned on successful execution of the API.
- 8001 - This constant is returned when the API call has invalid number of arguments.
- 8002 - This constant is returned when the API call has invalid type of arguments.
- 8003 - This constant is returned when the API call has invalid values for the container.
- 8004 - This constant is returned when the API call has an invalid Widget Identifier (Incase of MVC project).
Remarks
In MVC projects, you must use the APIs to communicate between the Form and the App Level Widget.
Communication from the Form to the App Level Widget
To communicate with the app level widget from the Form, you can use the executeOnAppLevelWidget function in the FormController:
var param = {
"container" : "flxSampleTemplate",
"eventName" : "testMethod",
"params" : {"test" : "data"}
}
this.executeOnAppLevelWidget(param);
In the code snippet, provide values for the following keys:
- container : The Template ID of the App Level Widget.
- eventName : The function name of the App Level Widget TemplateController to be executed.
- params: Any additional parameters to be passed to the function.
Communication from the App Level Widget to the Form
To communicate with the Form from the App level widget, you can use the executeOnCurrentForm function in the TemplateController:
var param = {
"eventName" : "testMethodInForm",
"params" : {"test" : "data"}
}
this.executeOnCurrentForm(param);
In the code snippet, provide values for the following keys:
- eventName : The function name of the FormController to be executed.
- params: Any additional parameters to be passed to the function.
Limitations
- The same Template cannot be used for both the Header and Footer in an app.
- The option to destroy an app level widget is currently not available.
- The height of the Form cannot be adjusted after the app level widget is rendered.
- In iOS apps, you must invoke the forcelayout method when you update the UI properties of an app level widget.
- In iOS apps, when the value of the adjustFormHeight parameter is set as false, you cannot perform actions on the UI that is present behind the app level widget (in cases where the UI overlaps with the app level widget).
- On Android devices that use OS API levels earlier than version 21, when the value of the adjustFormHeight parameter is set as false, users may observe flickering in the app level widget while navigating between the forms.
- In Android apps with a FlexContainer widget configured as a popup (the isModalContainer property of the FlexContainer widget is set as true), the app level widget is interact-able. If the area of the FlexContainer widget overlaps with the area of the app level widget, the app level widget appears over the FlexContainer widget.
Platform Availability
- Android
- iOS
The kony.application.setApplicationBehaviors function enables your app to configure its response to various events.
Syntax
kony.application.setApplicationBehaviors(Objectbehaviors);
Input Parameters
Objectbehaviors
A JavaScript object that contains key-value pairs which specify the app's response to various events. The object includes the following key-value pairs.
| Key | Value |
|---|---|
| blurEffectStyleInBackground | A value from the Blur Effect Constants that blurs the app's most recent screen when it is in the background. This value is ignored if the value of the enableSplashScreen key is true. |
| breakpoints | Sets the various breakpoints for the form for responsive web design. |
| calendarMonthYearSelectionDropdownView |
This property is used to set the Calendar widget popup to the new(dropdown) view. If the value of this attribute is true, the Calendar widget will be displayed in the new(dropdown) look. The default value of this key is false. This property is supported on Desktop Web only. NOTE: If an app is developed on V9 SP2 GA, you can’t change the Calendar widget popup to the old view. However, if an app is developed V9 SP1 GA or before and is imported into V9 SP2 GA, the calendar widget popup will be in the old(grid) view, to change it to a new(dropdown) look, you should change the property to true. Ex. kony.application.setApplicationBehaviors( |
| defaultIndicatorColor | Sets the color for the progress indicator. A Hex code or a word can be used to set the color. The words can only be used for two colors (white and grey), and these words are not case sensitive. The defaultIndicatorColor key is only supported on Android. The default color might vary for each platform as it picks from the application's theme, form color or predefined colors. |
| dismissSIPinCallbacks |
Enables users to dismiss the soft inputs such as keyboard and rotating wheel from the mobile screen. Using the This property is available only on the iOS platform. Following are the possible values of the
NOTE: Users can set the Example: kony.application.setApplicationBehaviors(
{ "dismissSIPinCallbacks": constants.DISMISS_SIP_IN_CALLBACKS_NO }
)
|
| enableLazyLoadForSegment |
A Boolean value that, when set to IMPORTANT: The lazy loading feature is only available for Segments present in a Responsive Web App that is built in the CSS Library mode (with the Enable JS Library Mode (Legacy) option disabled in the Project Settings). If the Enable JS Library Mode (Legacy) option is enabled for the app, the lazy loading feature does not work at run-time, and the loadingPlaceholderImage property does not appear. NOTE: From Quantum Visualizer V9 ServicePack 3, the default value set for this parameter is TRUE. If you want to disable the lazy loading experience for a Segment, set the value of the As Lazy loading only loads selective segment rows, the row animations and the onRowDisplay event callbacks are only triggered for the segment rows that are loaded. NOTE: Support for this property has been introduced in the Quantum Visualizer V9 ServicePack 2 Fixpack 7 release. |
| enableNSURLSession | A Boolean value that, when set to true, sets all network requirements to be served with NSURLSession. Setting this to false restores the current behavior which uses NSURLConnection. |
| enableRichTextContentAlign |
A Boolean value that sets the contentAlignment property of the RichText Widget.
NOTE:
Example:
|
| enableSplashScreen | A Boolean value that causes a splash screen to be displayed when the app is in the background when set to true, or disables the splash screen when set to false. The default is true. Available on iOS. |
| filterTouchesWhenObscured |
Tap jacking is a technique that is used by hackers to steal sensitive data by using a screen overlay mechanism. For example, a hacker can place a textbox over the password textbox in a login page by using the screen overlay mechanism. When an app user enters some data in the password text box, the data is actually entered in the textbox placed by the hacker and relays the information to the hacker. The filterTouchesWhenObscured parameter is a Boolean value that, when set to true, protects the application from Tap jacking security issues. When a screen overlay is present, this property filters the touch propagation to the app screen. The default value of this parameter is NOTE: This parameter is only available on the Android. Example:
|
| fontScaleFactor |
A Boolean value that sets the scale factor in pre/post app init. When configured, fonts in the app will scale accordingly. Configure this only once in the app life cycle to avoid ambiguous behavior. JavaScrip developers must add the following snippet in pre/post init. Example:
var deviceInfo = kony.os.deviceInfo();
if (deviceInfo["model"] == "iPhone 6 Plus")
{
kony.application.setApplicationBehaviors(
{fontScaleFactor:2.25}
);
}
else if (deviceInfo["model"] == "iPhone 6")
{
kony.application.setApplicationBehaviors(
{fontScaleFactor:1.24}
);
}
else if(deviceInfo["model"] == "iPhone 5C")
{
kony.application.setApplicationBehaviors(
{fontScaleFactor:0.98}
);
}
|
| hideDefaultLoadingIndicator | A Boolean value that hides the loading indicator when set to true, or shows it when set to false. |
| hideDefaultLoadingIndicator | A Boolean value that, if set to true, hides the default loading indicator that appears when a background operation is performed. The hideDefaultLoadingIndicator key is available only on Android and it is supported from Quantum Android plug-in GA 5.0.32 onwards. |
| invokePreshowPostShowEventsOnDeviceBack | A Boolean value that selects whether the pre-show or post-show events are triggered when the user presses the Back option on a device. |
| isI18nLayoutConfigEnabled |
A Boolean value that enables or disables the layout mirroring support for Quantum Visualizer Applications. It is a global application-level parameter. This parameter is passed as an input for the kony.application.setApplicationBehaviors API, and is available from V8 SP4 onwards.
If you assign the isI18nLayoutConfigEnabled key as false, the layout mirroring feature of your application is disabled.
Available on iOS and Android. |
| isPopupModel | A Boolean value that specifies whether the pop-up is modal. The value set as the property for a pop-up takes precedence over the value set dynamically. |
| marginsIncludedInWidgetContainerWeight | A Boolean value that applies the margin calculations when set to true. Margins are calculated based on width of the parent box. |
| prefersHomeIndicatorAutoHidden (available only from iOS 11) |
A Boolean value that specifies to auto hide the virtual home indicator that is introduced in iPhoneX bezel less display. This virtual home indicator is used instead of the physical home button. Apple takes care of when to auto hide the virtual home indicator if the value is set to true. The default value is false. Sample code: function setHomeInidicatorAutoHidden(){
kony.application.setApplicationBehaviors(
{"prefersHomeIndicatorAutoHidden" : true}
);
}
|
| restoreformstateondeviceback | A Boolean value that specifies whether the default behavior of form app menu state is retained when the user presses the Back button on the device. |
| retainSpaceOnHide | A Boolean value that specifies whether the space allocated for a widget is retained when the widget is made invisible. For more information, see the Remarks section below. |
| skipEscapeHTML |
A Boolean value that allows HTML tags in Label widgets when set to true, or disallows them when set to false.
|
| useNativeMSG | A Boolean value that, when set to true, enables your app to use native multistep gradients that are scaled relative to the size of the widget. Otherwise, set to false to disable this behavior. |
Example
// The application must call the following kony.application.setApplicationBehaviours()in Pre Appinit() methods
kony.application.setApplicationBehaviors({"stopLoadingScreenDismissOnFormNavigation":true})
//The application must call kony.application.setApplicationBehaviors(appTable) in Post Appinit() methods
function setApplicationBehaviors() {
//Controlling the behaviours by setting invokePreshowPostShow
//EventsOnDeviceBack as true,isPopupModel as true,and retainSpaceOnHide as true.
kony.application.setApplicationBehaviors({
invokePreshowPostShowEventsOnDeviceBack: true,
isPopupModel: true,
retainSpaceOnHide: true,
"hideDefaultLoadingIndicator": true
});
}
var inputParamTable = {};
inputParamTable.isScrollEventsAsync = false;
inputParamTable.isLowLevelEventsAsync = false;
inputParamTable.isGestureEventsAsync = false;
kony.application.setApplicationBehaviors(inputParamTable);
Return Values
None.
Remarks
This function enables you to specify whether:
- The pre-show and post-show events are invoked if you press Back option on a mobile device.
- Pop-ups are modal.
- The app menu needs to be updated when the pre-show and post-show events are invoked if you press the Back option on a mobile device.
Your app's menu has to be configured in pre-show/post show of each form if each form has separate app menu buttons or items. But on some platforms, the pre-show and post-show events are triggered when the user navigates back using Back option. On other platforms, those events are not triggered. If the pre-show/post-show event is not triggered, the form cannot update its app menu. In this scenario, ideally, the form must retain its app menu which it set earlier.
To ensure consistency while porting applications across platforms, the kony.application.setApplicationBehaviors function enables you to set the default behavior of pre-show and post-show events, a pop-up, and app menu.
NOTE: This function can only be called in the post-appinit event handler.
Parameter Details
The following provides more information about the key-value pairs in the Objectbehaviors parameter.
This key is applicable to widgets placed in a percentage container.
Height changes to the max height of the visible child widget.When retainSpaceOnHide property is made False, inconsistency among platforms is observed. If any of the widgets placed inside a container are made invisible, then some platforms will retain the space and some platforms will not retain the space. To overcome this inconsistency or to retain the space in all platforms, retainSpaceOnHide property must be configured to True. The default value of retainSpaceOnHide property is True.
Platform Availability
Available on all platforms
This API allows you to set a badge value to an application icon on the mobile desktop at the top-right corner of the application icon. If you pass an empty string as a parameter, the badge applied on the application icon is removed.
Syntax
kony.application.setApplicationBadgeValue(badgeValue, tileID);
Input Parameters
| Parameter | Description |
|---|---|
| badgeValue [String] - Mandatory | Value of the badge. The value that you specify in the badgeValue parameter appears within the badge. Do not pass any other value except a numerical value. For example, to set a badge value for an appicon, specify the value as "2" instead of 2. If the length of the badge value is greater than 1 the badge is a rounded rectangle. For example, if you specify the value of the badge as 88, the number appears in a rounded rectangular badge. If the length of the badge value is 1, the badge is always a circle. |
Example
settingBadge: function() {
this.view.btnBadge.setBadge("0", ""); //Set badge value on button widget
kony.application.setApplicationBadgeValue("" + 0);
},
BadgeIncrease: function() {
var counter = kony.os.toNumber(this.view.btnBadge.getBadge()) + 1; // read badge value from button and increment it with 1
kony.print("this gets executed " + counter + "type is " + typeof(counter));
this.view.btnBadge.setBadge("" + counter, ""); // Set badge value on the button widget
kony.application.setApplicationBadgeValue("" + counter); //Set badge value on app iconThe badge appears as follows when you execute the code given above:
![]()
Return Values
None
UI Behavior
The badge appears with white font on a red background. The shape of the badge varies with its value:
- If the badge value is a single digit, the badge shape is a circle.

- If the badge value contains multiple digits, the badge shape is a rectangle with rounded corners and borders.


Platform Availability
- iOS
This API captures the callback events for various states of the application which include:
- onactive - state which indicates that the mobile device is active and application is running
- oninactive - state which indicates that the mobile device is inactive and application is running
- onbackground - state which indicates that the application is active and running in the background.
For more information on iOS application behavior on background, click here
- onforeground - state which indicates that the application is active and running in the foreground
- onappterminate - state which indicates that the application is terminated and not running.
- onkeyboardchange - state which indicates whether a keyboard is deployed for an application.
- onpowersourcechange - state which indicates whether if a power source is attached to a device.
- onmultiwindowmodechanged - state that indicates whether the application changes from full-screen mode to multi-window mode, or vice-versa.
- onnetworkchange - this is specific to Mango. This state occurs whenever there is a change in the following:
- Status - Indicates the status of the device. The different statuses are Connected, Disconnected, Roaming or Unknown.
- Network- Indicates the network available on the device. The network statuses are Wireless80211, Ethernet, MobileBroadbandGSM, MobileBroadbandCDMA, or None.
- Date - Indicates the date on which the event occurs.
- onapplicationopenurl - To support interprocess communication (IPC) message authentication,
Quantum Visualizer provides an application callback
onapplicationopenurl. Theonapplicationopenurlcallback is used if an application needs to authenticate another application. To use this callback, applications must register with it. Theonapplicationopenurlcallback takessourceApplication,url, andannotation (via UIDocumentInteractionController)as input parameters. If the developer chooses to process the commands/information, True must be returned. If the developer chooses to ignore the commands/information passed, then False must be returned.
NOTE: Android supports only the onbackground, onmultiwindowmodechanged, and onforeground states.
Syntax
kony.application.setApplicationCallbacks(callbacks);
Input Parameters
callbacks [Object] - Mandatory
Specifies an Object with key as appstate and value as the callback function for the corresponding appstate. The following are the different appstates possible:
- onappterminate: This state which indicates that the application is terminated and not running.
Callbacks specific to Android
Common keys for the dictionary argument
The callbacks ondpichange, onsizechange, and onvisibleboundschange are called with a dictionary as the argument with the following keys.
| Key | Description |
|---|---|
| width [double] | The current window width |
| height [double] | The current window height |
| currentform [Form widget] | The current visible form |
| orientation [constant] |
Gets the current orientation (landscape or portrait) of the window (app view) with respect to the display. The possible values are:
|
| isFullScreen [boolean] | Specifies whether the current window is full screen. This value is true if the window is full screen; false if it is not. |
| isFullScreenMode [boolean] |
NOTE: This key will have some value only after enterFullScreenMode() or exitFullScreenMode() is called. |
| visibleWidth [double] | Gets the visible width of the window (app view). The visible region is the region not obstructed by chrome such as the status bar or app bar. |
| visibleHeight [double] | Gets the visible height of the window (app view). The visible region is the region not obstructed by chrome such as the status bar or app bar. |
| dpi [double] | Gets the pixels per logical inch of the current environment. |
| nativeOrientation [constant] |
Gets the native orientation of the display monitor. This is typically the orientation where the buttons on the device match the orientation of the monitor. The possible values are:
|
| resolutionScale [double] | Gets the scale factor of the immersive environment. |
| rawPixelsPerViewPixel [double] | Gets a value representing the number of raw (physical) pixels for each view (layout) pixel. |
| interactionMode [double] |
Gets a value that indicates whether the user is interacting with the view using a mouse or touch. The possible values are: 0 : Mouse 1 : Touch |
| viewstate [constant] |
Specifies the state of the current window (app view). The state indicates the orientation (landscape or portrait) and whether the app is snapped. The possible values are:
|
Callbacks specific to iOS
Example
//onactive function
function test() {
alert("===============Test executed=======");
}
//oninactive function
function test1() {
alert("===============Test1 executed=======");
}
//onbackground function
function test2() {
alert("===============Test2 executed=======");
}
//onforeground function
function test3() {
alert("===============Test3 executed=======");
}
//onappterminate function
function test4() {
alert("===============Test4 executed=======");
}
//onScreenCapture function
function screenCaptureCallback() {
alert("===============screenCaptureCallback executed=======");
}
//setcallbackfunction
function setCallBacks() {
alert("===============setApplicationCallbacks executed=======");
var callbacksObj = {
onactive: test,
oninactive: test1,
onbackground: test2,
onforeground: test3,
onappterminate: test4,
onScreenCapture : screenCaptureCallback
};
kony.application.setApplicationCallbacks(callbacksObj);
}
//onapplicationopenurl
kony.application.setApplicationCallbacks({
onapplicationopenurl: callbackFunction
});
Example 1.
function callbackFunction(sourceApplicaion, url, annotation) {
var flag = false;
if (sourceApplication == "AppOne" && url == "appTwo://….") {
flag = true;
}
return flag;
}
Example 2.
function callbackFunction(sourceApplicaion, url, annotation) {
var flag = false;
if (annotation) //annotation can be nil as well… refer parameter description… {
if (annotation[key1] == 10) {
flag = true;
}
return flag;
}
//onWatchRequest sample code
function jsfunction(requestObject) {
return <returnValue > ;
}
kony.application.setApplicationCallbacks({
onwatchrequest: jsfunction
})
//requestObject– is a dictionary of key value pairs.
//Returnvalue– Any JS Object consisting of numbers, strings and boolean data types.
Return Values
None
Exceptions
An error is thrown if input is invalid or does not follow the expected structure.
- 100 - Invalid type pf parameters.
- 101 - Invalid number of arguments.
- 102 - Invalid input error
Platform Availability
Available on all platforms except Desktop Web.
This API is used to configure all initialization events such as, preappinit, postappinit, init, appservice, showstartupform and so on. The application lifecycle is as follows:
IMPORTANT: This API must be invoked only once during the application lifecycle. You should NOT invoke this API as part of the application lifecycle, because Quantum Visualizerwill generate the code that invokes the API automatically. Invoking this API multiple times will result in an undefined behavior.
Syntax
kony.application.setApplicationInitializationEvents(callbacks);
Input Parameters
callbacks [Object] - Mandatory
Is a Hash table which comprises of the following key value pairs:
| Key | Description |
|---|---|
| preappinit[params] |
This is an existing event that the developer registers in the IDE per application basis. This event consists of any logic that needs to be executed before the initialization of forms, skins, and any other application initialization activities. For e.g loading the i18n resource bundles dynamically etc. |
| init[params] | init is generated by the code and consists of the form and skin initialization data. |
| postappinit[params] |
Is an existing event that the developer registers in the IDE per application basis. Developers use this function to define logic that needs to be executed before the first form is shown and after the application is initialized. NOTE: postappinit can return a form handle. If postappinit returns a form handle, then the platform shows the form returned from the postappinit callback, otherwise the platform invokes the showstartupform function. |
| appservice[params] |
The closure provided against appservice will be invoked by the platform in a sequence. This function also returns the form handle. NOTE: appservice can return a form handle. If appservice returns a form handle, then the platform shows the form returned from the appservice callback. If appservice does not return a form handle, the platform invokes the showstartupform function. NOTE: If both postappinit and appservice return the form handle then, the form returned by app service is given priority by the platforms. |
| showstartupform[params] |
This is a method invoked by the platform to show the startup form, as indicated in the IDE. NOTE: This event is invoked only when postappinit returns a nil. If appservice returns a form handle, showstartupform is not invoked. |
Example
//onactive function
function test() {
alert("===============Test excuted=======");
}
//oninactive function
function test1() {
alert("===============Test1 excuted=======");
}
//onbackground function
function test2() {
alert("===============Test2 excuted=======");
}
//onforeground function
function test3() {
alert("===============Test3 excuted=======");
}
//onappterminate function
function test4() {
alert("===============Test4 excuted=======");
}
//setAppInitialization function
function setAppInitializationEvents() {
kony.application.setApplicationInitializationEvents({
init: test,
preappinit: test1,
postappinit: test2,
appservice: test3,
showstartupform: test4,
deeplink: test5
});
alert("===============setAppInitializationEvents excuted=======");
}Return Values
None
Exceptions
- 102 - InvalidInputError: An error is thrown if input is invalid.
- 100- TypeError: An error is thrown when the type is invalid.
Platform Availability
Available on all platforms.
This API enables you to set the application mode to Native, Hybrid, or Wrapper.
Syntax
kony.application.setApplicationMode(Integer constant);
Input Parameters
| Parameter | Description |
|---|---|
| Integer Constant |
|
Example
function setApplicationMode(){
kony.application.setApplicationMode(APPLICATION_MODE_NATIVE);
}
Return Values
None
Special Considerations
This API should be called only in preappinit or before the execution of preappinit. If this API is invoked elsewhere in the program, it is invalid and leads to undefined behavior.
Exceptions
Error
Platform Availability
Available on all platforms.
The API enables you to set properties at the application level.
Syntax
kony.application.setApplicationProperties(key-value pairs);
Input Parameters
statusBarColor
Sets the color for a device's status bar.
statusBarForegroundColor
Sets the foreground color of a device's status bar; the color of each item (text, icon, and so on) displayed on the status bar. This parameter is not available on Android.
statusBarHidden
Hides or reveals the status bar.
You can achieve hidden status bar behavior by setting at Application level and at Form level as well. At the Application level, you can achieve the behavior by defining either statusBarHidden parameter, and also using the systemUiConfig parameter with value as IMMERSIVE_STICKY_HIDE_STATUS_BAR in the API.
When you define both statusBarHidden and systemUiConfig parameters in the API, the systemUiConfig parameter takes the precedence.
At the Form level, you can achieve the behavior using the statusBarHidden property and the systemUiConfig property. The following table provides the precedence levels when hidden status bar behavior is set using both properties at the Form level and both parameters at the application level (only when the systemUiConfig parameter's value is IMMERSIVE_STICKY_HIDE_STATUS_BAR) as well.
NOTE: The statusBarHidden flag is cleared when you move the application to the background and then bring it back to the foreground. So, the status bar is displayed by default when you move the application back to the foreground.
| Property/ Parameter | Precedence Level |
|---|---|
| systemUiConfig Property (Form Level) | 1 |
| systemUiConfig Parameter (Application Level) | 2 |
| statusBarHidden Property (Form Level) | 3 |
| statusBarHidden Parameter (Application Level) | 4 |
Example
Form.statusBarHidden : true;
statusBarStyle
Sets a style for the status bar. This parameter is not available on Android.
For more information on the input parameters, refer the status bar properties.
navigationBarColor
Sets the color for a device's navigation bar. Applicable only for Android. For more information, refer to the navigationBarColor property.
systemUiConfig
Controls the behavior of the status and navigation bars. Applicable only for Android. For more information, refer to the systemUiConfig property.
You can define any one of the following:
| Constants | Descriptions |
|---|---|
| SYSTEM_UI_DEFAULT | Resets any of the following modes set previously. |
| DIM_SYSTEM_BARS | Dims the status and navigation bars, and space occupied them are retained as is. |
| HIDE_STATUS_BAR | Hides the status bar and space occupied by it is not retained. User can reveal it by swiping downward from the top of the screen or by tapping anywhere on the screen |
| HIDE_NAVIGATION_BAR | Hides the navigation bar and space occupied by it is not retained. User can reveal it by swiping upward from the bottom of the screen or by tapping anywhere on the screen. |
| HIDE_SYSTEM_BARS | Hides both status and navigation bars and space occupied by them are not retained. User can reveal it by swiping downward from the top of the screen, by swiping upward from the bottom of the screen, or by tapping anywhere on the screen. |
| HIDE_STATUS_BAR_KEEP_LAYOUT_STABLE | Hides the status bar and space occupied by it is retained. Resetting this mode is same as HIDE_STATUS_BAR. |
| HIDE_NAVIGATION_BAR_KEEP_LAYOUT_STABLE | Hides the navigation bar and space occupied by it is retained. Resetting this mode is same as HIDE_NAVIGATION_BAR. |
| HIDE_SYSTEM_BARS_KEEP_LAYOUT_STABLE | Hides both status and navigation bars and space occupied by them are retained. Resetting this mode is same as HIDE_SYSTEM_BARS. |
| IMMERSIVE_HIDE_STATUS_BAR | Hides the status bar and space occupied by it is not retained. Unlike HIDE_STATUS_BAR, this mode can be reset only when user reveals the status bar by swiping downward from the top of the screen. |
| IMMERSIVE_HIDE_NAVIGATION_BAR | Hides the navigation bar and space occupied by it is not retained. Unlike HIDE_NAVIGATION_BAR, this mode can be reset only when user reveals the navigation bar by swiping upward from the bottom of the screen. |
| IMMERSIVE_HIDE_STATUS_BAR_KEEP_LAYOUT_STABLE | Hides the status bar and space occupied by it is retained. Resetting this mode is same as IMMERSIVE_HIDE_STATUS_BAR. |
| IMMERISIVE_HIDE_NAVIGATION_BAR_KEEP_LAYOUT_STABLE | Hides the navigation bar and space occupied by it is retained. Resetting this mode is same as IMMERSIVE_HIDE_NAVIGATION_BAR. |
| IMMERSIVE_HIDE_SYSTEM_BARS | Hides both status and navigation bars, and space occupied by them are not retained. Unlike HIDE_SYSTEM_BARS, user can reset this mode by revealing them by swiping down from the top of the screen or swiping upward from the bottom of the screen. |
| IMMERSIVE_HIDE_SYSTEM_BARS_KEEP_LAYOUT_STABLE | Hides both status and navigation bars, and space occupied by them are retained. Resetting this mode is same as IMMERSIVE_HIDE_SYSTEM_BARS. |
| IMMERSIVE_STICKY_HIDE_STATUS_BAR | Hides the status bar and space occupied by it is not retained. User cannot reset this mode. When user swipes down from the top of the screen, the status bar appears momentarily and disappears. |
| IMMERSIVE_STICKY_HIDE_STATUS_BAR_KEEP_LAYOUT_STABLE | Hides the status bar and space occupied by it is retained. User cannot reset this mode. When user swipes down from the top of the screen, the status bar appears momentarily and disappears. |
| IMMERSIVE_STICKY_HIDE_NAVIGATION_BAR | Hides the navigation bar and space occupied by it is not retained. User cannot reset this mode. When user swipes upward from the bottom of the screen, the navigation bar appears momentarily and disappears. |
| IMMERSIVE_STICKY_HIDE_NAVIGATION_BAR_KEEP_LAYOUT_STABLE | Hides the navigation bar and space occupied by it is retained. User cannot reset this mode. When user swipes upward from the bottom of the screen, the navigation bar appears momentarily and disappears. |
| IMMERSIVE_STICKY_HIDE_SYSTEM_BARS | Hides both status and navigation bars, and space occupied by it is not retained. User cannot reset this mode. System bars appears momentarily when user tries to reveal them by swiping downward from the top of the screen or by swiping upward from the bottom of the screen. |
| IMMERSIVE_STICKY_HIDE_SYSTEM_BARS_KEEP_LAYOUT_STABLE | Hides both status and navigation bars, and space occupied by it is retained. System bars appears momentarily when user tries to reveal them by swiping downward from the top of the screen or by swiping upward from the bottom of the screen. |
NOTE: The systemUIConfig flag is cleared when you move the application to the background and then bring it back to the foreground. So, the status bar/navigation bar is displayed by default when you move the application back to the foreground.
Example
function setApplicationProperties(){
kony.application.setApplicationProperties({
"statusBarColor": "ffff0000",
"statusBarForegroundColor": "ff0000",
"statusBarHidden": true,
"statusBarStyle": constants.STATUS_BAR_STYLE_LIGHT_CONTENT,
"navigationBarColor" : ffff0000,
"systemUiConfig" : constants.HIDE_SYSTEM_BARS
});
}Return Values
None
Special Considerations
The setApplicationProperties API is an application-level API and accepts key-value pairs as an input. When you set properties using the API to an application, the properties get applied to all the artifacts available in the application.
The properties can be applied at the application-level and at the form-level as well. When you set the properties to a form (form-level), the properties get applied only to that particular form in the visible region. When a user navigates to another form, the status and navigation bars may change based on the properties set to that form. Otherwise, the status and navigation bar behaves based on the properties set at the application-level. If the properties are set at both form level and application level, the properties set at the form level overrides the property set at the application level. If the properties are not set at the form-level and at the application-level, the device’s default settings are applied to status and navigation bars.
Exceptions
Error
Platform Availability
Available on all platforms.
NOTE: The statusBarForegroundColor and statusBarStyle input parameters are not available on Android.
This API allows you to set a badge value to the specified app menu item on the top-right corner of the app menu item. If you pass an empty string as the parameter, the badge value of the app menu item is cleared.
Syntax
kony.application.setAppMenuBadgeValue(appmenuID, menuItemId, badgeValue);
Input Parameters
| Parameter | Description |
|---|---|
| appMenuId [String] - Mandatory |
If you are setting the badge for an app menu item that was created dynamically, use the same ID that was used to create the app menu item.If you are setting the badge for an app menu item that was created from the IDE, use the ID available in the generated script file. |
| menuItemId [String] - Mandatory | Id of the app menu item to which the badge value to be set. |
| badgeValue [String] - Mandatory | Value of the badge. The value you specify in the badge value appears within the badge. If the length of the badge value is greater than 1 the badge is a rounded rectangle. For example, if you specify the value of the badge as 88, the number appears in a rounded rectangular badge. If the length of the badge value is 1, the badge is always a circle. The maximum number of characters that can be specified in a badge value is 9. If the badge value id beyond 9 only the first 9 characters are displayed. |
Example
createAppMenu: function() {
var appMenuItem1 = ["appmenuitemid1", "Accounts", "option1.png", this.onClickMenuItem1];
var appMenuItem2 = ["appmenuitemid2", "Examination", "option2.png", this.onClickMenuItem2];
var appMenu = [appMenuItem1, appMenuItem2];
kony.application.createAppMenu("SampleAppMenu", appMenu, null, null);
kony.application.setCurrentAppMenu("SampleAppMenu");
kony.application.setAppMenuBadgeValue("SampleAppMenu", "appmenuitemid1", "4");
kony.application.setAppMenuBadgeValue("SampleAppMenu", "appmenuitemid2", "6");
},
Return Values
None
UI Behavior
The following image depicts how a bade appears on an app menu item:
Platform Availability
- iOS
This API sets the bookmark state to the URL. This API accepts the formID and a json structure of key value pairs which will be added to the URL of the page.
Syntax
kony.application.setBMState(formID, State);
Input Parameters
| Parameter | Description |
|---|---|
| formID [String] - Mandatory | Identifier of the form to be bookmarked. |
| state [JSON Object] - Mandatory | A JSON object comprising key value pairs. The key value pairs are user defined. You cannot specify this as a nested structure. i.e the value part can not be another JSON object. |
Example
setState: function() {
var state = {
Bookmark: "about",
text: "About"
};
kony.application.setBMState("Form1", state);
alert("A new state is set to the URL ");
},Return Values
None
Platform Availability
- Desktop Web
This API is used to set the alignment of the checkBox selection image.
Syntax
kony.application.setCheckBoxSelectionImageAlignment(SelectionImageAlignment);
Input Parameters
| Parameter | Description |
|---|---|
| SelectionImageAlignment [String] - Mandatory |
One of the following string can be provided:
|
Example
kony.application.setCheckBoxSelectionImageAlignment(constants.CHECKBOX_SELECTION_IMAGE_ALIGNMENT_RIGHT);
Return Values
None
Exceptions
If input is invalid, an error is displayed.
Platform Availability
- iOS
Sets the font name and font size of various app menu items in the current app menu.
Syntax
kony.application.setCurrentAppMenuFont(fontname,fontsize);
Input Parameters
| Parameter | Description |
|---|---|
| fontname |
A JavaScript string that corresponds to a particular font name. NOTE: If you want to set the system font to the required size, you must pass the fontname as “System,” or “System-Bold,” or “System-Italic.” |
| fontsize | A float value that corresponds to a specific font size. |
Example
kony.application.setCurrentAppMenuFont("System-Italic", 12);
Return Values
None
Platform Availability
- iOS
This API customizes the default paddings applied for a ListBox. Generally, default padding is appended to padding applied through layout configurations of the widget.
Syntax
kony.application.setDefaultListboxPadding(bool);
Input Parameters
| Parameter | Description |
|---|---|
| bool [Boolean] - Mandatory |
Indicates if the default padding is set.
|
Example
kony.application.setDefaultListboxPadding(false);
Return Values
None
Platform Availability
- iOS
- Android
This API customizes the default paddings applied for a Textbox. Generally, default padding is appended to padding applied through layout configurations of the widget.
Syntax
kony.application.setDefaultTextboxPadding(bool);
Input Parameters
| Parameter | Description |
|---|---|
| bool [Boolean] - Mandatory |
Indicates if the default padding is set.
|
Example
kony.application.setDefaultTextboxPadding(false);
Return Values
None
Platform Availability
- iOS
This API is used to register a listener or a callback that receives request from a Native app to launch the Quantum Visualizer Library without UI or in headless mode. The kony.application.setLibraryHeadlessModeCallback API is available from V8 SP3 onwards.
For more information about how to build an application in library mode, click here.
NOTE: The kony.application.setLibraryHeadlessModeCallback API is only applicable when the app is launched in library mode.
Syntax
kony.application.sendLibraryResultHeadlessModeCallback(callback);
Input Parameters
| Parameter | Description |
|---|---|
| callback |
This parameter registers a function that receives the Native app's data as key-value pairs. The function registered in the callback parameter has the following syntax. function callback(libraryArgs) { } libraryArgs This parameter contains a JavaScript object with key-value pairs. This JavaScript object contains the data that is passed from the nNative app to the Quantum Visualizer Library based depending on the contract of the Quantum Visualizer Library. |
Example
function callback(libraryArgs)
{
if (libraryArgs != null)
{
/* Use the data passed in libraryArgs and perform the required operation.
The result of the operation can be sent back to the native app using the sendLibraryResultToNativeApp API.*/
kony.application.sendLibraryResultToNativeApp(resultData);
};
}
kony.application.setLibraryHeadlessModeCallback(callback);
Return Values
None.
Important Considerations
-
The sendLibraryResultHeadlessModeCallback API must be set in either the pre-appinit or post-appinit event of the application.
-
If you invoke this API more than once, the application only considers the callback that was set during the last instance.
Platform Availability
- Android
- iOS
This API sets the ImageWidget width to minimum or maximum according to available width or image width in absence of reference width. If ImageWidget is smaller than the available width, it is aligned using the widget alignment rules.
Syntax
kony.application.setRespectImageSizeForImageWidgetAlignment(bool);
Input Parameters
| Parameter | Description |
|---|---|
| bool [Boolean] - Mandatory |
Indicates if the default padding is set.
|
Example
kony.application.setRespectImageSizeForImageWidgetAlignment(true);
Return Values
None
Implementation Details
If this API is not used, the Image widget width is always the given width and image is center aligned.
Platform Availability
- iOS
Sets a flag indicating that the current form is ready to be cached for search engine optimization.
Syntax
kony.application.setSeoDataReadyFlag();
Example
// This function is added to the form.
function seoReady() {
kony.application.setSeoDataReadyFlag(); }
Input Parameters
None.
Return Values
None
Remarks
You app should only call the setSeoDataReadyFlag function after all service call responses are processed, all required data is rendered, and the Quantum Visualizer form is ready to be cached. A good time for your app to invoke the setSeoDataReadyFlag function is when it is processing the form's postShow event.
This API allows you to display a loading screen (following a certain color schema) to the user while another action is in progress. The loading screen can be defined in such a way it can either block the UI or does not block the UI. Typically, the loading screen is a semi-transparent screen over-laid on the current form.
Use Case
You can use this API to display a loading screen to the end user with a specific skin attached to it in the following scenarios:
- on invoking a service
- on executing a user-defined function that takes some time for execution.
Syntax
kony.application.showLoadingScreen(skin, text, position, isBlocked, showProgressIndicator, properties);
Input Parameters
| Parameter | Description |
|---|---|
| skin [skin identifier] - Mandatory |
The skin to be applied to the loading screen. All the skin attributes supported by different platforms are applicable. This is a reference to an existing skin. If it is nil, the native platform skin is applied. |
| text [String] - Mandatory |
The text to be displayed when displaying the loading screen. For example, "Searching flights...". If it is nil, no text is displayed. |
| position [String] - Mandatory |
Indicates the position of the loading screen, whether it should occupy the entire screen or just the center of the screen. The possible values for position are :
NOTE: Currently only center and fullscreen are supported. |
| isBlocked [Boolean] - Mandatory |
Indicates if the UI should be blocked.
If nothing is specified, default value is used. |
| showProgressIndicator [Boolean] - Mandatory |
Indicates if the progress indicator should be displayed.
NOTE: The progress indicator is a set of animating images. |
| properties [Object] - Mandatory |
Indicates the platform specific properties to be applied to the loading screen. NOTE: You must pass this parameter as nil on all platforms except iPhone platform. |
The following are the key-value pairs to be passed in the properties table for iPhone:
The following are the key-value pairs to be passed in theproperties table for all platforms except iPhone:
| Key | Description |
|---|---|
| progressIndicatorColor (String) |
Color is applied for progress indicator when it is shown. (Optional) NOTE: All colors with RGBA (Hex code) are supported, but for "white" and "gray" you can pass it as a string value. Color value should be similar to the value provided in the theme. |
Example
//Invoking showLoadingScreen on iPhone platform.
kony.application.showLoadingScreen(null, "testf",
constants.LOADING_SCREEN_POSITION_ONLY_CENTER, false, true, {
shouldShowLabelInBottom: "true",
separatorHeight: 200,
progressIndicatorType: constants.PROGRESS_INDICATOR_TYPE_SMALL,
progressIndicatorColor: "Gray"
});
//Invoking showLoadingScreen on other platform.
kony.application.showLoadingScreen("loadskin", "LoadingScreen", constants.LOADING_SCREEN_POSITION_ONLY_CENTER, false, true, {
enableMenuKey: true,
enableBackKey: true,
progressIndicatorColor: "ffffff77"
});
NOTE: Ensure that you define the Pre Appinit event of the app as follows:kony.application.setApplicationBehaviors({"stopLoadingScreenDismissOnFormNavigation":true})
Return Values
None
Platform Availability
Available on all platforms.
When invoked, this API starts a foreground service that runs continuously even when an application is running in the background, i.e. when the user is not directly interacting with the app.
The foreground services display notifications to send updates to the users. The notifications can be customized using updateForegroundNotification API.
Foreground service can be started in scenarios which require your app to be actively running after being placed in the background or after turning the device's display off.
Some sample use cases include navigation while driving, tracing the path while running, and playing music. For more information, refer here.
NOTE: Ensure that you have done the following:
- In the androidbuild.properties file, set the value of the
locationListenerTypeproperty toalways.
Appropriate entries are added to the AndroidManifest.xml file depending on the type of the location listener. - Enable the Use Google Play Location Services checkbox in the Project Settings > Native > Android section.
- From the Quantum Visualizer 202306 release, if the Target SDK API level of the app is set as 33, and the app uses the Foreground Service APIs, you must enable support for runtime permissions for notifications.
To do so, navigate to Project Settings > Native > Android Mobile / Tablet, and add thePOST_NOTIFICATIONpermission in the Permissions tab.
Syntax
kony.application.startForegroundService(foregroundServiceType,notificationConfig);
Input Parameters
| Parameter | Description |
|---|---|
| foregroundServiceType[Constant] - Mandatory |
Specifies the type of the foreground service. The available foreground service type constant is kony.service.LOCATION. |
| notificationConfig- Mandatory |
An object with notification properties. Following are the properties:
|
Example
var notificationConfig= {
title : "Notification Title",
body : "Notification Content",
actions:[ {actionType: kony.application.LAUNCH_ACTIVITY,
actionText: "Launch Activity", actionCallback: activityActionCallback}]
};
kony.application.startForegroundService(kony.service.LOCATION,notificationConfig);
function activityActionCallback() {
}
Return Values
None
Remarks
When you invoke this API, the foreground process starts in the same process as the current app.
If a user exits from the application (manually kills the app or activity) either by using the back button or by removing the app from the recent apps screen, the state of the application does not change. Due to the retention of the application state, users might observe the following issues when the application is relaunched:
- After the app launches, the app displays the same screen (form) that appeared before the user exited from the app.
- The app does not display the loading screen and displays the last screen (form) that appeared before the user exited from the app.
- The pre-app-init and post-app-init callbacks are not invoked when the app is relaunched.
To avoid these issues, ensure that you register the app for ActivityLifeCycle Callbacks by using the KonyMain.addActivityLifeCycleListener, and reset the application state variables and Form states in the activity onCreate() Callback.
Platform Availability
Android
When invoked, this API enables you to stop the foreground service for an application that is running in the background.
NOTE: Ensure that you have done the following:
- In the androidbuild.properties file, set the value of the
locationListenerTypeproperty toalways.
Appropriate entries are added to the AndroidManifest.xml file depending on the type of the location listener. - Enable the Use Google Play Location Services checkbox in the Project Settings > Native > Android section.
- From the Quantum Visualizer 202306 release, if the Target SDK API level of the app is set as 33, and the app uses the Foreground Service APIs, you must enable support for runtime permissions for notifications.
To do so, navigate to Project Settings > Native > Android Mobile / Tablet, and add thePOST_NOTIFICATIONpermission in the Permissions tab.
Syntax
kony.application.stopForegroundService(foregroundServiceType);
Input Parameters
| Parameter | Description |
|---|---|
| foregroundServiceType[Constant] - Mandatory |
Specifies the type of the foreground service. The available foreground service type constant is kony.service.LOCATION. |
Example
kony.application.stopForegroundService(kony.service.LOCATION);
Return Values
None
Platform Availability
Android
This API specifies that the application must not timeout after a defined period of inactivity (time difference between the current device time and the last time you clicked on any user interface component). This API unregisters the application from idletimeout.
Use Case
This API must be used in case you do not want to track the idle time, i.e., do not want to logout even if the application is inactive for a specific time interval.
Syntax
kony.application.unregisterForIdleTimeout();
Example
function unregisterForIdleTimeout() {
kony.application.unregisterForIdleTimeout();
alert("====unRegister======");
}
Input Parameters
None
Return Values
None
Rules and Restrictions
This API is applicable only when the Form property Enable Time Out is set to true. For more information about Enable Time Out property, see Widget User Guide.
Platform Availability
Available on all platforms.
When invoked, this API enables you to customize and update the existing notifications shown by the foreground service.
NOTE: Ensure that you have done the following:
- In the androidbuild.properties file, set the value of the
locationListenerTypeproperty toalways.
Appropriate entries are added to the AndroidManifest.xml file depending on the type of the location listener. - Enable the Use Google Play Location Services checkbox in the Project Settings > Native > Android section.
- From the Quantum Visualizer 202306 release, if the Target SDK API level of the app is set as 33, and the app uses the Foreground Service APIs, you must enable support for runtime permissions for notifications.
To do so, navigate to Project Settings > Native > Android Mobile / Tablet, and add thePOST_NOTIFICATIONpermission in the Permissions tab.
Syntax
kony.application.updateForegroundNotification([foregroundServiceType,notificationConfig);
Input Parameters
| Parameter | Description |
|---|---|
| foregroundServiceType[Constant] - Mandatory |
Specifies the type of the foreground service. The available foreground service type constant is kony.service.LOCATION. |
| notificationConfig- Mandatory |
An object with notification properties. Following are the properties:
|
Example
var notificationConfig= {
title : "Location Details",
content : "Longitude : 17.3850, Latitude: 78.4867",
actions:[ {actionType: kony.application.LAUNCH_ACTIVITY,
actionText: "Launch Activity", actionCallback: activityActionCallback}, {actionType: kony.application.CUSTOM,
actionText: "Remove Foreground Service, actionCallback: serviceActionCallback}]
};
kony.application.updateForegroundNotification(kony.service.LOCATION,notificationConfig);
function activityActionCallback() {
}
function serviceActionCallback() {
}
Return Values
None
Platform Availability
Android
This API returns the protocol being used by the browser to display the content. For example, http or https.
Syntax
kony.application.getBrowserProtocol();
Example
function browserProtocol(){
kony.application.getBrowserProtocol();
}
Input Parameters
None
Return Values
String - http or https.
Platform Availability
Responsive Web
This API returns the base URL that is being used in the browser.
Syntax
kony.application.getBaseURL();
Input Parameters
None
Example
function baseURL(){
kony.application.getBaseURL();
}
Return Values
String - the base URL of the browser.
Platform Availability
Responsive Web
This API removes the specified query params and their values from the URL of the browser.
Syntax
kony.application.removeQueryParamsByKey(params);
Input Parameters
| Parameter | Description |
|---|---|
| params | The query params that must be deleted. |
Example
var params = {<params>}
kony.application.removeQueryParamsByKey(params);
Return Values
String - the base URL of the browser.
Platform Availability
Responsive Web