Back

ConfirmCredential

Hello World

This plugin demonstrates how you can use device credentials (PIN, Pattern, Password) in your app to authenticate the user before they are trying to complete some actions.

To use ConfirmCredential, you must first load the plugin at the top of your script using the LoadPlugin method like this:

app.LoadPlugin( "ConfirmCredential" )

Checks if the device's screen lock is active.

app.IsScreenLockActive()Boolean

Example - Check for Screen Lock

app.LoadPlugin( "ConfirmCredential" )

function OnStart()
{
    var isLockActive = app.IsScreenLockActive();
    app.Alert( isLockActive, "IsScreenLockActive" );
}
    Copy     Copy All       Run      

Creates the Confirm Credentials screen.

app.ShowAuthScreen( callback, duration )

duration: If the user has unlocked the device Within the last this number of seconds. it can be considered as an authenticator. (Default: 30)

Example - Show the Confirm Credentials Screen

app.LoadPlugin( "ConfirmCredential" )

function OnStart()
{
    app.ShowAuthScreen( OnAuthResult );
}

function OnAuthResult( isConfirmed, errorMessage )
{
    app.Alert( isConfirmed ? "Success" : errorMessage );
}
    Copy     Copy All       Run      
function( isConfirmed, errorMessage )
seconds