The kony.localAuthentication namespace provides the functions to authenticate, get the status of the authentication mode, and cancel authentication.
Note: For information about how to enable the Face ID feature in your Kony Visualizer application, click here. For information about how to detect whether a device supports either the Touch ID or Face ID feature, refer the getBiometryType API.
This namespace contains the following API elements.
The kony.localAuthentication namespace provides the following functions.
The API is used to authenticate the user.
Note: You can use this API for both the Touch ID and Face ID features. For information about how to detect whether a device supports either the Touch ID or Face ID feature, refer the getBiometryType API.
Note: Call the kony.localAuthentication.authenticate
API only if the kony.localAuthentication.getStatusForAuthenticationMode
API returns the success status code (5000).
Syntax
kony.localAuthentication.authenticate(
authenticationMode,
statusCallback,
configMap)
Input Parameters
Parameter | Description |
---|---|
authenticationMode | Specifies the authentication mode for which the status is requested. The data type is constant. For more information on authentication modes, see Authentication Modes. |
statusCallBack (status, message) |
A callback conveys the status of the authentication with appropriate status and message. The default value is nil. For status code, see the Status Codes section. Note: For Android, the |
configMap |
Specifies the configuration dictionary for the specified authentication mode. The configMap parameter uses keys listed in the table below.
|
Example
function statusCB(status, message) { if(status == 5000) { kony.ui.Alert({ message: "AUTHENTICATION SUCCESSFULL", alertType: constants.ALERT_TYPE_INFO, yesLabel: "Close" }, {}); } else { var messg = status + message; kony.ui.Alert({ message: messg, alertType: constants.ALERT_TYPE_INFO, yesLabel: "Close" }, {}); } } function authUsingTouchID() { var configMap = { "promptMessage": "PLEASE AUTHENTICATE USING YOUR TOUCH ID", "fallbackTitle": "Please enter your Password" }; kony.localAuthentication.authenticate(constants.LOCAL_AUTHENTICATION_MODE_TOUCH_ID, statusCB, configMap); }
Return Values
No
Remarks
The authentication mode with the Touch ID (LOCAL_AUTHENTICATION_MODE_TOUCH_ID) requires a message to display that prompts a user to provide authentication. The key to be used is “promptMessage”. You can also pass another key-value pair, fallbackTitle in the configMap parameter to customize the label title of the "Enter Password" button.
Below is a sample configMap:
var configMap = {"promptMessage" : "PLEASE AUTHENTICATE USING YOUR TOUCH ID",
"fallbackTitle" : "Please enter your Password"};
Note: Depending on the type of authentication available, the promptMessage is either PLEASE AUTHENTICATE USING YOUR TOUCH ID or PLEASE AUTHENTICATE USING YOUR FACE ID.
Note: If you assign an empty string, “ ” to the fallbackTitle key, the Enter Password button will be hidden. If the fallbackTitle key is not defined in the configMap parameter, the default (Enter Password) value is displayed.
Platform Availability
This API differentiates whether a device supports either the Touch ID or Face ID feature. The kony.localAuthentication.getBiometryType API is available from iOS 11.
Syntax
kony.localAuthentication.getBiometryType()
Example
function getBiometryTypeOfDevice() { var promptMessage = "Sign in with "; switch (kony.localAuthentication.getBiometryType()) { case constants.BIOMETRY_TYPE_NONE: // Handle the case if the device doesn't support any biometryType break; case constants.BIOMETRY_TYPE_TOUCHID: promptMessage += "TouchID"; break; case constants.BIOMETRY_TYPE_FACEID: promptMessage += "FaceID"; break; case constants.BIOMETRY_TYPE_UNDEFINED: // Handle the case if the device is not a iOS11 device or later break; } }
Return Values
Return Value | Description |
---|---|
constants.BIOMETRY_TYPE_NONE | If there is no biometric authentication in the device. |
constants.BIOMETRY_TYPE_TOUCHID | If the device supports Touch ID authentication. |
constants.BIOMETRY_TYPE_FACEID | If the device supports Face ID authentication. |
constants.BIOMETRY_TYPE_UNDEFINED | If this API is called on the device with OS earlier than iOS11. |
Remarks
Face ID is the new biometric authentication that Apple has introduced with iPhoneX. This API will help to customize the prompt message in kony.localAuthentication.authenticate. Depending on the type of authentication available, the prompt message is Sign in with FaceID or Sign in with TouchID.
Platform Availability
The API cancels the current authentication process.
Syntax
kony.localAuthentication.cancelAuthentication()
Example
var cancelButton = kony.ui.Button({ onClick: btnOnClick }); function btnOnClick() { kony.localAuthentication.cancelAuthentication() }
Return Values
Return Value | Description |
---|---|
status | The 5002 status code is returned indicating the authentication is canceled. |
Remarks
The API is available only for the Android platform. You can use this API for the Cancel button placed in the authentication dialog box. When user taps the Cancel button, the API is called to cancel the authentication process.
Platform Availability
The API returns the status of the authentication mode.
Note: You can use this API for both the Touch ID and Face ID features. For information about how to detect whether a device supports either the Touch ID or Face ID feature, refer the getBiometryType API.
Syntax
kony.localAuthentication.getStatusForAuthenticationMode(
authenticationMode)
Input Parameters
Parameter | Description |
---|---|
authenticationMode | Specifies the authentication mode for which the status is requested. The data type is constant. For the authentication modes, see Authentication Modes. |
Example
function isAuthUsingTouchSupported() { var status = kony.localAuthentication.getStatusForAuthenticationMode(constants.LOCAL_AUTHENTICATION_MODE_TOUCH_ID); if (status == 5000) { kony.ui.Alert({ message: "AUTHENTICATION BY TOUCHID SUPPORTED", alertType: constants.ALERT_TYPE_INFO, yesLabel: "Close" }, {}); } else { var msg = "TOUCHID AUTHENTICATION RETURNED THE STATUS ::" + status; kony.ui.Alert({ message: status, alertType: constants.ALERT_TYPE_INFO, yesLabel: "Close" }, {}); } }
Return Values
Return Value | Description |
---|---|
status | A status code is returned indicating the support for local authentication using Touch ID or Face ID. For information about how to detect whether a device supports either the Touch ID or Face ID feature, refer the getBiometryType API. |
Remarks
Using the API, you can verify whether local authentication is supported on the device.
The API also returns different status codes based on the state of the device. For status codes, see the Status Codes section.
Platform Availability
The following is an authentication mode and Touch ID or Face ID is used for authentication.
Note: You can use the same constant for the Face ID feature. For information about how to detect whether a device supports either the Touch ID or Face ID feature, refer the getBiometryType API.
The following table provides a list of status codes and their descriptions.
Status Codes | Description |
---|---|
5000 | No Error |
5001 | Authentication is not successful because a user fails to provide valid credentials. |
5002 | Authentication is canceled by a user. For example, a user taps Cancel in the dialog box. |
5003 | Authentication is canceled because a user taps the fallback button (Enter Password). This is applicable only for the iOS platform. |
5004 | Authentication is canceled by system. This is applicable only for the iOS platform. |
5005 | Authentication does not start because the passcode is not set on the device. |
5006 | Authentication does not start because Touch ID or Face ID is not available on the device. |
5007 | Authentication does not start because Touch ID has no enrolled fingerprints or Face ID has no enrolled face recognition. |
5008 | Authentication does not start because the target device's OS does not support local authentication with Touch ID or Face ID. This is applicable only for the iOS platform. |
5009 | Authentication was not successful because there were too many failed Touch ID attempts, and the Touch ID feature has now been locked. This is applicable only for the iOS platform. |
Rev | Author | Edits |
7.1 | NC | NC |
Copyright © 2013 Kony, Inc. All rights reserved. |