kony.net Namespace
The kony.net namespace, which is a part of the Network API, contains the following API elements.
Functions
The kony.net namespace contains the following functions.
This API cancels only async network calls. Synchronous calls have a platform-specific cancellation mechanism provided by the platform (mechanism may vary from platform to platform).
Syntax
kony.net.cancel(connHandle);
Input Parameters
| Parameter | Description |
|---|---|
| connHandle | The handle to the asynchronous service. connHandle is returned by invokeserviceasync. |
Example
function cancelService() {
kony.net.cancel(connHandle);
}
Return Values
None
Exceptions
1200 - Network Error
Remarks
Invalid parameters to this function are ignored.
Platform Availability
Available on all platforms.
Removes cookies from the client that are associated with the specified domain.
Syntax
kony.net.clearCookies(url, cookieName);
Input Parameters
| Parameter | Description |
|---|---|
| url | An optional string that specifies a valid URL of a domain from where the cookies were obtained. |
| cookieName | An optional array of strings that specifies the cookie names that are to be removed from the current application. |
Example
kony.net.clearCookies("http://www.google.com");
Return Values
None
Remarks
In an application where service calls are made through Browser Widget or through native service calls, cookies are sent from the servers to maintain the session. These cookies are stored in the cookie store on the client side. Using this API you can remove the cookies of a particular domain obtained through all of HttpRequest, invokeServiceAsync and browser widget.
If you specify the optional parameters url and cookieName, then all the cookies with the specified name related to that URL are removed from your application. The parameter url should be the complete URL. For example, http://www.gooogle.com. If the URL is not valid, then this API will not remove the cookies. An exception is shown of type KonyError with the error code as 1005 and error name/message as "invalid input url".
If the scheme of the URL is "https" then all the cookies of https as well as http will be removed. If the scheme of the URL is "http" then only the cookies stored for http will be removed. If the cookies are not present in the application cookie store in the provided array of cookieNames, then this API will not perform any action and does not raise an exception.
Platform Availability
- iOS
- Android
Limitations
- Android
- The kony.net.clearCookies API does not remove the cookie from the Browser widget's cookie store; it replaces the cookie value with an empty string.
The FormData object represents an ordered collection of entries with name-value pairs. Call this function to create a FormData object.
Syntax
kony.net.FormData();
Example
var httpinputparams1 = new kony.net.FormData()
Input Parameters
None.
Return Values
Returns an object of type FormData.
Platform Availability
- Android
- iOS
Retrieves the currently-active network type.
Syntax
kony.net.getActiveNetworkType(optionsConfig);
Input Parameters
optionsConfig [JSON Object] - An optional JSON Object that contains the following parameters:
NOTE: This parameter is only available on the Android platform.
| Parameter | Description |
|---|---|
| requestWithPermission [Boolean] |
A Boolean parameter that is required to obtain information on a 2G or 4G network used. |
| callback [Function] | A callback function that is invoked when the value of the requestWithPermission parameter is set to true. The callback function is invoked with a JSON Object that contains the following parameters:
|
Example
function callbackFunction(network){
if(network.status != "FAILED"){
alert(JSON.stringify(network));
}
else{
alert("Failed to get network");
}
}
function checkActiveNetwork() {
var options = {
"requestWithPermission" : true,
"callback" : callbackFunction
};
return kony.net.getActiveNetworkType(options);
}
Return Values
If the device is offline, it will return null. Otherwise, it will return the appropriate connection type.
| Return Value | Description |
|---|---|
| constants.NETWORK_TYPE_2G | Indicates that a 2G network is used. |
| constants.NETWORK_TYPE_3G | Indicates that a 3G network is used. |
| constants.NETWORK_TYPE_4G | Indicates that a 4G network is used. |
| constants.NETWORK_TYPE_5G | Indicates that a 5G network is used. |
| constants.NETWORK_TYPE_WIFI | Indicates that Wi-Fi is used for network connection. |
| constants.NETWORK_TYPE_ETHERNET | Indicates that Ethernet is used for network connection. Available only on the Desktop Web channel. |
| constants.NETWORK_TYPE_ANY | Indicates that the device has sufficient network coverage to send data over any supported data channels, especially on Desktop Web applications. |
For Android, if the value of the requestWithPermission parameter is true, the network information is passed to the callback function, and a null value is returned to the API. If the value of the requestWithPermission parameter is false, the appropriate connection type constant is returned.
For Desktop Web, it will always return constants.NETWORK_TYPE_ANY.
Remarks
Desktop Web depends upon the navigator.onLine property to detect if the device is offline or online. The implementation of this property across browsers is uneven. For more information, refer to Mozilla documentation for browser support.
Platform Availability
Available on all platforms.
Retrieves cookies associated with the specified domain.
Syntax
kony.net.getCookies(URL, cookieFormat) ;
Input Parameters
Example
var cookies = kony.net.getCookies("http://www.google.com", constants.COOKIES_IN_STRING );
for (index = 0; index < cookies.length; index++) {
cookie = cookies[index];
kony.print("Cookie is: " + cookie);
}
Return Values
Returns an array of cookies. For details, see Remarks below.
//For example
SSID=Ap4P….GTEq; Domain=foo.com; Path=/; Expires=Wed, 13 Jan 2021 22:23:01 GMT; Secure; HttpOnly
Remarks
In an application where service calls are made through Browser Widget or through native service calls, cookies are sent from the servers to maintain the session. These cookies are stored in cookie store on the client side. The kony.net.getCookies API enables access to the cookies for a particular domain. The URL is given as an input parameter to kony.net.getCookies API, then all cookies related to that domain are returned.
In the current application context, you can also access cookies for a particular domain stored in cookie store on the client side or device.
The kony.net.getCookies function returns all the cookies stored in local cookie store on the client side or device for that particular domain. The returned cookies can vary based on the domain (partial or full domain) and as well as the path.
The URL is passed as input and must be a fully formed, valid URL like http://www.google.com.
If the URL is invalid or not formed properly, Null is returned.
Each cookie that this function returns is a string that follows the format key=value. Each cookie string can also contain additional information following the Standard HTTP Cookie Format, such as Domain, Path, Expires, Secure, and HttpOnly. This function returns Null if there are no cookies for the domain.
If the scheme of the URL is https, then this function returns all the cookies of https cookies as well as the http cookies. If the scheme of the URL is http, then only the cookies stored for http are returned.
Platform Availability
Android and iOS
Determines the verification status of the specified domain.
Syntax
kony.net.getDomainVerificationUserState(domainString);
Input Parameters
| c | Description |
|---|---|
| domainString | The domain for which the verification status is to be determined. |
Example
var state = kony.net.getDomainVerificationUserState("temenos.com");
if (state == constants.DOMAIN_STATE_NONE) {
// show the dialog to provide some context to user to navigate settings screen.
} else if (state == constants.DOMAIN_STATE_VERIFIED) {
}
Return Values
A constant that determines the verification status of the specified domain. Following are the supported constants:
| Constant | Description |
|---|---|
| kony.constants.DOMAIN_STATE_VERIFIED |
Indicates that the domain has passed the Android App Links verification. |
| kony.constants.DOMAIN_STATE_SELECTED | Indicates that the domain has not passed Android App Links verification. However, it indicates that the user has associated with an app. |
| kony.constants.DOMAIN_STATE_NONE | Indicates that the domain has neither passed the Android App Links verification nor has a user associated with an app |
Platform Availability
- Android
Determines whether the device has the specified capability.
Syntax
kony.net.hasNetworkCapability(capability);
Input Parameters
capability
A constant that specifies the availability of a capability on the device. You can specify any of the following.
| Constant | Description |
|---|---|
| constants.NET_CAPABILITY_CAPTIVE_PORTAL |
Indicates that the network was found to have a captive portal in place during the last time it was probed. |
| constants.NET_CAPABILITY_CBS | Indicates that the network has an ability to reach the CBS servers of the network carrier that is used for carrier-specific services. |
| constants.NET_CAPABILITY_DUN | Indicates that the network has the ability to reach the DUN or tethering gateway of the network carrier. |
| constants.NET_CAPABILITY_EIMS | Indicates that the network has the ability to reach the Emergency IMS servers or other services of the network carrier used for network signaling during emergency calls. |
| constants.NET_CAPABILITY_FOREGROUND | Indicates that the network is available for use by apps, and is not a network that is being kept up in the background to facilitate fast network switches. |
| constants.NET_CAPABILITY_FOTA | Indicates that the network has the ability to reach the FOTA portal of the network carrier that is used for over the air updates. |
| constants.NET_CAPABILITY_IA | Indicates that the network has the ability to reach the Initial Attach servers of the network carrier. |
| constants.NET_CAPABILITY_IMS | Indicates that the network has the ability to reach the IMS servers of the network carrier that is used for network registration and signaling. |
| constants.NET_CAPABILITY_INTERNET | Indicates that the network must be able to reach the internet. |
| constants.NET_CAPABILITY_MCX | Indicates that the network has the ability to reach the Mission Critical servers of the network carrier. |
| constants.NET_CAPABILITY_MMS | Indicates that the network has the ability to reach the MMSC of the network carrier that is used to send and receive MMS messages. |
| constants.NET_CAPABILITY_NOT_CONGESTED | Indicates that the network is not congested. When a network is congested, applications must defer network traffic that can be done at a later point in time, such as uploading analytics. |
| constants.NET_CAPABILITY_NOT_METERED |
Indicates that the network is unmetered. |
| constants.NET_CAPABILITY_NOT_RESTRICTED | Indicates that the network is available for general use. This constant is set by default. If this constant is not set, applications must not attempt to communicate on this network. NOTE: This is simply informative and not enforcement - enforcement is handled via other means. |
| constants.NET_CAPABILITY_NOT_ROAMING | Indicates that the network is not roaming. |
| constants.NET_CAPABILITY_NOT_SUSPENDED | Indicates that the network is currently not suspended.
When a network is suspended, the IP addresses and any connections established on the network remain valid, but the network is temporarily unable to transfer data. This issue may be observed if a cellular network experiences a temporary loss of signal, such as while driving through a tunnel, etc. A network with this capability is not suspended, and so is expected to be able to transfer data. |
| constants.NET_CAPABILITY_NOT_VPN | Indicates that the network is not a VPN. This capability is set by default and must be explicitly cleared for VPN networks. |
| constants.NET_CAPABILITY_RCS | Indicates that the network has the ability to reach the RCS servers of the network carrier, used for Rich Communication Services. |
| constants.NET_CAPABILITY_SUPL | Indicates that the network has the ability to reach the SUPL server of the network carrier, used to retrieve GPS information. |
| constants.NET_CAPABILITY_TEMPORARILY_NOT_METERED | This capability is set for networks that are generally metered, but are currently unmetered, For example, when the user may not be in a particular area. This capability can be changed at any time. When this constant is not specified, the application is responsible for stopping any data transfer that must not occur on a metered network. |
| constants.NET_CAPABILITY_TRUSTED |
Indicates that the user has indicated implicit trust on this network. This constant is set by default. In general, this means that the network is a sim-selected carrier, a plugged-in ethernet, a paired Bluetooth device or a WiFi router that the user has requested connection to. Untrusted networks are probably limited to unknown WiFi access points. |
| constants.NET_CAPABILITY_VALIDATED | Indicates that the network connection is successfully validate. For example, on a network with NET_CAPABILITY_INTERNET, it means that the Internet connectivity was successfully detected. |
| constants.NET_CAPABILITY_WIFI_P2P | Indicates that the network has the ability to reach a Wi-Fi direct peer. |
| constants.NET_CAPABILITY_XCAP | Indicates that the network has the ability to reach the XCAP servers of the network carrier, used for configuration and control. |
Example
kony.net.hasNetworkCapability(constants.NET_CAPABILITY_TEMPORARILY_NOT_METERED);
Return Values
Boolean
Exceptions
None
Platform Availability
- Android
Creates an HttpRequest object.
Syntax
kony.net.HttpRequest(requestOptions);
Example
var httpRequestNew = kony.net.HttpRequest({
"timeoutIntervalForRequest": 60,
"timeoutIntervalForResource": 600
}
);
Input Parameters
requestOptions - An optional argument that can have the following parameters.
NOTE: The requestOptions parameter is only available on the Android and iOS platforms.
| Parameter | Description |
|---|---|
| timeoutIntervalForRequest [integer] |
An optional parameter that specifies the maximum connection time out value (in seconds) for the request to establish an HTTP connection. If the request is not established before the timeout interval is reached, a timeout error occurs. The timeoutIntervalForRequest parameter is only applicable for the Android and iOS platforms. On the Android platform, the default timeout value is zero, which means that the timeout is infinite. On the iOS platform, the timeoutIntervalForRequest parameter is only applicable for background network calls (when the backgroundTransfer property is set to true). If the timeout value is not specified, the default timeout value of 60 seconds is set by the OS. |
| timeoutIntervalForResource [integer] |
An optional parameter that specifies the maximum time out value (in seconds) for which the network must wait for a response from the server resource. If the resource is not retrieved before the timeout interval is reached, a timeout error occurs. The timeoutIntervalForResource parameter is only applicable for the Android and iOS platforms. On the Android platform, the default timeout value is zero, which means that the timeout is infinite. On the iOS platform, the timeoutIntervalForResource parameter is only applicable for background network calls (when the backgroundTransfer property is set to true). If the timeout value is not specified, the default timeout value of 1 week (7 days) is set by the OS. |
Return Values
None
Remarks
The HttpRequest Object supports an HTTP or HTTPS request to any resource on the network and fetches the response.
NOTE: SNI (Server Name Indication ) is supported from Android 4.2 onwards. That is, from API level >=17. From Android 4.0 to 4.2 versions, the support of SNI depends on device capability. That is 14<= API Level <17.
Platform Availability
Available on all platforms.
This API enables you to check whether a network is available for data transport on a device.
Syntax
kony.net.isNetworkAvailable(networkType, optionsConfig);
Input Parameters
| Parameter | Description |
|---|---|
| networkType [Integer] | An integer constant that specifies the network type on the device for data transport. You can specify any of the Network Constants. |
| optionsConfig [JSON Object] - Optional |
A JSON Object that contains the following parameter: requestWithPermission: A Boolean parameter that is required to obtain information on a 2G or 4G network used. NOTE: This parameter is only available on the Android platform. |
| Constant | Description |
|---|---|
| constants.NETWORK_TYPE_2G | Indicates that a 2G network is used. |
| constants.NETWORK_TYPE_3G | Indicates that a 3G network is used. |
| constants.NETWORK_TYPE_4G | Indicates that a 4G network is used. |
| constants.NETWORK_TYPE_5G | Indicates that a 5G network is used. |
| constants.NETWORK_TYPE_WIFI | Indicates that Wi-Fi is used for network connection. |
| constants.NETWORK_TYPE_ETHERNET | Indicates that Ethernet is used for network connection. Available only on the Desktop Web channel. |
| constants.NETWORK_TYPE_ANY | Indicates that the device has sufficient network coverage to send data over any supported data channels, especially on Desktop Web applications. |
Example
function checkIfNetworkIsAvailable() {
var options = {
"requestWithPermission" : true
}
return kony.net.isNetworkAvailable(constants.NETWORK_TYPE_ANY, options);
}
Return Values
Boolean
Returns true if the specified data network is available, or false if not.
Platform Availability
Available on all platforms.
Sets a client certificate to be used for HTTPS client authentication.
Syntax
kony.net.loadClientCertificate(certParamsTable);
Input Parameters
certParamsTable
A list of following key-value pairs required to load client certificate for client authentication in a mutually authenticated HTTPS connection.
| Key | Description |
|---|---|
| cert | Can be of type RawBytes or base64String. Specifies the certificate to be loaded. The certificate should be of type PKCS12 certificate encoding format, which holds both client certificate and private key. |
| pass | A string containing the password that is protecting the PKCS12 certificate. If PKCS12 certificate is not password protected, use an empty string; that is, “ ”. |
Example
function loadCert() {
try {
var certFileName = kony.io.FileSystem.getCacheDirectoryPath() + "/" + clientCertFileName;
var certFile = new kony.io.File(certFileName);
var certStream = certFile.read()
var certParamTable = {
cert: certStream,
pass: "password"
};
var res = kony.net.loadClientCertificate(certParamTable);
kony.print("loadClientCertificate status = " + res)
} catch (e) {
alert(e);
}
}Return Values
This API returns a Boolean value whether the client certificate is loaded successfully or not.
Remarks
The following functions use the client authentication feature:
- kony.net.invokeServiceAsync
- kony.net.send
If loading the client certificate succeeds, the previously-loaded certificate is replaced with new one.
If loading the client certificate fails, the previously-loaded certificate is retained as is.
Any certificate loaded using this function is automatically unloaded as soon as the application exits.
NOTE: When you use the kony.net.HttpRequest API in sync mode, both server and client pinning do not work in the iOS platform.
Exceptions
If the mandatory parameters are missing, following error codes occur.
100 - invalid type of parameters
101 - invalid number of arguments
Platform Availability
- iOS
- Android
Invokes a Quantum Fabric service asynchronously.
Syntax
kony.net.mfintegrationsecureinvokerasync(inputParams, serviceName , operationName, callbackFunction);
Input Parameters
| Parameter | Description |
|---|---|
| inputParams | An object containing the Parameters for the Quantum Fabric service. The format of this object is dependent on the input requirements of the Quantum Fabric service being invoked. |
| serviceName | A string that holds the name of the service to invoke. |
| operationName | A string that specifies the name of the service's operation. |
| callbackFunction | A callback function to handle the service's response. |
Example
function callbackFunction(status, response) {
//application specific code goes here.
}
var serviceName = "ServiceTwo";
var operationName = "HealthOperation";
// inputParams here is just a sample. Your Parameters will look different.
// The Parameters are dependent on the input information that your
// Quantum Fabric service's operation requires.
// <place-holder> is a placeholder for the atual values of your parameters.
var inputParams = {
"q": "<place-holder>",
"httpheaders": {
"api-key": "<place-holder>"
}
};
mfintegrationsecureinvokerasync(inputParams, serviceName, operationName, callbackFunction);
Return Values
None
Remarks
Use this service to call a Quantum Fabric service from your app. When the service sends a response to your app, the response is processed by the callback function that your app passes through the callbackFunction parameter of this function.
The format of the inputParams object parameter is not specified here because its format depends entirely on the information that the Quantum Fabric service's operation requires for input.
The function passed through the callbackFunction parameter must match the following Syntax.
callbackFunction(status,response);
The callback function takes two parameters. The first, called status, is an integer that indicates the status of the response from the service's operation The value contained in the status parameter depends on the service itself.
The second parameter to the callback function is called response. It is a JavaScript object that contains the response from the service's operation. The format of the object and the data it contains is dictated by the service's operation.
Clears the default cache of an application by removing all responses received from URLs.
Syntax
kony.net.removeAllCachedResponses();
Example
kony.net.removeAllCachedResponses();
Input Parameters
None
Return Values
None.
Platform Availability
- iOS
Removes already loaded client certificate.
Syntax
kony.net.removeClientCertificate();
Example
function removeCert() {
kony.net.removeClientCertificate();
}
Input Parameters
None
Return Values
None
Exceptions
None
Platform Availability
- Android
Disables intregity checks for HTTP calls between the client and the server.
Syntax
kony.net.removeIntegrityCheck();
Example
kony.net.removeIntegrityCheck();
Input Parameters
None
Return Values
None
Determines if the device has a 5G network connection to the app.
Syntax
kony.net.set5GNetworkListener(callback);
Input Parameters
callback - The callback function that must be executed after the execution of the API call is complete.
| Constant | Description |
|---|---|
| constants.OVERRIDE_NETWORK_TYPE_NR_NSA_MMWAVE | The override network type when the device is connected to the LTE network and has E-UTRA-NR Dual Connectivity(EN-DC) capability or is currently connected to the secondary 5G cellular network. |
| constants.OVERRIDE_NETWORK_TYPE_NR_NSA | The override network type when the device is connected to the LTE network and has E-UTRA-NR Dual Connectivity(EN-DC) capability or is currently connected to the secondary 5G cellular network. |
| constants.OVERRIDE_NETWORK_TYPE_LTE_ADVANCED_PRO | The override network type when the device is connected to the advanced pro LTE cellular network. |
| constants.OVERRIDE_NETWORK_TYPE_LTE_CA | The override network type when the device is connected to the LTE cellular network and is using carrier aggregation. |
| constants.OVERRIDE_NETWORK_TYPE_NONE | No configured network override. |
Example
callbackFunction : function(networktype){
if(networktype = constants.OVERRIDE_NETWORK_TYPE_LTE_CA)
alert("LTE_CA");
}
kony.net.set5GNetworkListener(callbackFunction);Return Values
Constant
Exceptions
None
Platform Availability
- Android
NOTE: You can unregister from the 5G Network Listener by invoking the kony.net.unregister5GNetworkListener() API.
Adds cookies in the main app cookie storage. If a cookie with the same name, domain, and path already exists in storage, this API replaces the specified cookie in the cookie storage.
Syntax
kony.net.setCookies(url,cookiesList);
Input Parameters
| Parameter | Description |
|---|---|
| url |
A string that specifies a valid URL of a domain where the cookies are to be defined. If the url is empty, a specific cookie is stored based on the cookie acceptance policy. |
| cookiesList |
An array of objects, that each contains details of a cookie in the dictionary format. Sample dictionary format: {
|
Example
function setCookiesFunc() {
var lisOfCookies = [{
"Name": "appName",
"Value": "App01",
"Domain": "app.example.com",
"Path": "/"
}];
kony.net.setCookies("https://www.example.com", listOfCookies);
}Return Values
None
Remarks
To successfully create a cookie, you must provide values for (at least) the Path, Name, Value, and the Domain keys. All the other valid keys must start with capital letters.
The parameter url must be the complete URL. For example, http://www.gooogle.com.
Platform Availability
- iOS
Enables the addition of checksums to HTTP calls for HTTP integrity checking.
Syntax
kony.net.setIntegrityCheck(propertiesTable);
Input Parameters
propertiesTable
A JavaScript object that contains the following key-value pairs.
| Key | Description |
|---|---|
| algo |
A string that specifies the hashing algorithm to use for the checksum. The following values are supported:
|
| salt | A string containing an app-supplied random data value that is used as additional input to the hash function. The salt argument has a maximum string length of 1024 characters. If it is longer, the excess characters are truncated. Your app can pass an empty string for this argument if you feel that a salt value is not necessary. |
| headerName | A non-empty string that specifies the name of the header. The maximum length of this string is 64 characters. If more characters are passed, the headerName argument is truncated to 64 characters. |
| validateResp | A Boolean value that indicates whether the response should be validated. A value of true means that the response checksum needs to be validated, while false indicates that it does not. For important details, see the Remarks section below. |
| hostNameList | An optional array of strings that specify the URLs of servers. When the client app on the device communicates with the specified servers, it adds integrity checking headers to each HTTP request. For more information, see the Remarks section below. |
Example
var propertiesTable {
algo: “SHA256”,
salt: “secret_123”,
headerName: “X - Checksum”,
validateResp: true,
hostNamesList: [“mail.kony.com”, “cloud.kony.com”]
};
kony.net.setIntegrityCheck(propertiesTable);Return Values
None
Exceptions
This function throws the following exceptions.
| Error Code | Description |
|---|---|
| 100 | Invalid argument or parameter name. |
| 101 | Missing argument or parameter, |
| 102 | Invalid number of arguments. |
Remarks
Use this function to cause the Quantum VisualizerAPI Framework to use checksums to validate HTTP messages passing between the client app and the servers.
The beginning and ending whitespace is automatically trimmed on all string arguments in the propertiesTable parameter .
If the validateResp argument in the propertiesTable parameter is set to true, your app uses an HttpRequest object to receive the response. When it does, it uses the integrityStatus property of the HttpRequest object to check whether the integrity check is successful or not.
If the optional hostNameList argument is omitted from the propertiesTable parameter, then the integrity checking header is added to all outgoing HTTP and HTTPS calls. However, if the host names are specified in the hostNameList argument, then the integrity checking header is only added to calls to the specified hosts. Also, only basic validation is performed on the named hosts' parameters if the hostname strings are limited to the set [a-z, A-Z, 0-9, -]. In addition, the wildcard character, which is the asterisk (*), can only be used as a prefix. For example, *.kony.com is valid, but kony.* is not. Finally, you must ensure that all of the host names you pass are valid. The setIntegrityCheck function does not validate the format of the host names for you. All host names must follow the standard delineated in the Wikipedia Hostname topic.
Platform Availability
- Android
- iOS
This function allows the developer to register for network status changes.
Syntax
kony.net.setNetworkCallbacks(callbackconfig);
Input Parameters
| Parameter | Description |
|---|---|
| callbackconfig | A JSON object that contains a property called statusChange.
|
Example
var config = {};
config.statusChange = function(isOnLine) {
if (isOnLine) {
alert("Device is online");
} else {
alert("Device is offline");
}
};
kony.net.setNetworkCallbacks(config);
Return Values
None
Remarks
This function allows the developer to register for network status changes. You can then change the user experience according to the network availability.
Platform Availability
Available on all platforms.
Unregister from the 5G Network Listener.
Syntax
kony.net.unregister5GNetworkListener();
Input Parameters
None
Example
kony.net.unregister5GNetworkListener();
Return Values
None
Exceptions
None
Platform Availability
- Android
Converts a URL string from application/ x-www-form-urlencoded format in the UTF-8 encoding.
Syntax
kony.net.urlDecode(queryParams,exemptionString);
Input Parameters
| Parameter | Description |
|---|---|
| queryParams | A string in application/x-www-form-urlencoded format in the UTF-8 to decode. |
| exemptionString | Optional. Specify the characters in the string that should be exempted from decoding. The parameter is used only on iOS . The Android platform ignores this parameter. |
Example with exemptionString parameter
var result = kony.net.urlDecode(“hello*_%40+world”); kony.print(result);
//iOS output
hello*_%40+worl%64
//Android output
hello*_%40+world
Example without exemption String parameter
var result = kony.net.urlDecode(“hello*_%40+world”); kony.print(result);
//Output for all platforms
“hello*_@ world”
Return Values
Returns a string containing the decoded URL.
Platform Availability
- Android
- iOS
Converts a URL string into application/x-www-form-urlencoded format using the UTF-8 encoding.
Syntax
kony.net.urlEncode(queryParams, exemptionString);
Input Parameters
| Parameter | Description |
|---|---|
| queryParams | A string containing a URL to encode. |
| exemptionString | Optional. A string that specifies the characters in the string that should be exempted from encoding. The parameter is used only on iOS. The Android platforms ignores this parameter. |
Example with exemption String parameter
var exemptionString = "helloworl-*_."; var result = kony.net.urlEncode(“hello*_@ world”, exemptionString); kony.print(result);
//iOS output
hello*_%40+worl%64
//Android output
hello*_%40+world
Example without exemption String parameter
var result = kony.net.urlEncode(“hello*_@ world”); kony.print(result);
//Output for all platforms
hello*_%40+world
Return Values
Returns the encoded string.
Remarks
The string is encoded based on the following rules.
- The following characters remain the unchanged.
- a-z
- A-Z
- 0-9
- Period (.), hyphen (-), asterisk (*), and underscore (_)
- The space character " " is converted to a plus symbol (+).
- Other characters are unsafe and are first converted to one or more bytes using an encoding scheme. Each byte is represented as 3-character string, %xy, where xy is the two-digit hexadecimal representation of the byte.
Platform Availability
- Android
- iOS