I have used https://gonative.io/ to package the app and add native functionality including biometric log in.
The full custom code block accesses the GoNative functionality to return the user email and password from the stored promise that is set when a user first logs in to the app (you will see I have used email calls to test the stages)
This works with Android phone and the user is logged in. iOS returns the error.
gonative.auth.status({‘callbackFunction’: gonative_status_beforelogin}); // returns promise
var bodyParts = new Backendless.Bodyparts();
bodyParts.textmessage = “1”;
bodyParts.htmlmessage = “1”;Backendless.Messaging.sendEmail( “promise has been returned”,
bodyParts,
[ “luczentar@mina.group” ],
)
.then( function( response ) {
console.log( “message has been sent” );
})
.catch( function( error ) {
console.log( "error " + error.message );
})function gonative_status_beforelogin(data) {
if (data && data.hasTouchId && data.hasSecret) {
// Prompt the user to use the fingerprint to log in
gonative.auth.get({‘callbackFunction’: gonative_secret_callback});
}
}var bodyParts = new Backendless.Bodyparts();
bodyParts.textmessage = “2”;
bodyParts.htmlmessage = “2”;Backendless.Messaging.sendEmail( “fingerprint prompt works”,
bodyParts,
[ “luczentar@mina.group” ],
)
.then( function( response ) {
console.log( “message has been sent” );
})
.catch( function( error ) {
console.log( "error " + error.message );
})function gonative_secret_callback(data) {
if (data && data.success && data.secret) {
var credentials = JSON.parse(data.secret);
var username = credentials.username;
var password = credentials.password;// Use username and password to do login here, // e.g. an http post or ajax request // const Backendless = require('backendless')
/*
Or useimport Backendless from 'backendless'
for client side.
If you don’t use npm or yarn to install modules, you can add the following lineto your index.html file and use the global Backendless variable.
*///Backendless.initApp(‘8518B92E-A6AA-5589-FFA0-B863E4A63F00’, ‘xxx’)
var bodyParts = new Backendless.Bodyparts();
bodyParts.textmessage = “3”;
bodyParts.htmlmessage = “3”;Backendless.Messaging.sendEmail( “secret callback happened”,
bodyParts,
[ “luczentar@mina.group” ],
)
.then( function( response ) {
console.log( “message has been sent” );
})
.catch( function( error ) {
console.log( "error " + error.message );
})var bodyParts = new Backendless.Bodyparts();
bodyParts.textmessage = “4”;
bodyParts.htmlmessage = “4”;Backendless.Messaging.sendEmail( username,
bodyParts,
[ “luczentar@mina.group” ],
)
.then( function( response ) {
console.log( “message has been sent” );
})
.catch( function( error ) {
console.log( "error " + error.message );
})const onSuccess = user => {
const pageName = minaPageURL
const pageData = { logedUser: user }var bodyParts = new Backendless.Bodyparts();
bodyParts.textmessage = “6”;
bodyParts.htmlmessage = “6”;Backendless.Messaging.sendEmail( “on success email”,
bodyParts,
[ “luczentar@mina.group” ],
)
.then( function( response ) {
console.log( “message has been sent” );
})
.catch( function( error ) {
console.log( "error " + error.message );
})//BackendlessUI.Navigator.goToPage(pageName)
BackendlessUI.Navigator.goToPage(pageName, pageData)var bodyParts = new Backendless.Bodyparts();
bodyParts.textmessage = “7”;
bodyParts.htmlmessage = “7”;Backendless.Messaging.sendEmail( “gotopage executed”,
bodyParts,
[ “luczentar@mina.group” ],
)
.then( function( response ) {
console.log( “message has been sent” );
})
.catch( function( error ) {
console.log( "error " + error.message );
})
}const onError = error => {
console.error('Server reported an error: ', error.message)
//console.error('error code: ', error.code)
//console.error('http status: ', error.status)var bodyParts = new Backendless.Bodyparts();
bodyParts.textmessage = “8”;
bodyParts.htmlmessage = “8”;Backendless.Messaging.sendEmail( error.message,
bodyParts,
[ “luczentar@mina.group” ],
)
.then( function( response ) {
console.log( “message has been sent” );
})
.catch( function( error ) {
console.log( "error " + error.message );
})
}var bodyParts = new Backendless.Bodyparts();
bodyParts.textmessage = “5”;
bodyParts.htmlmessage = “5”;Backendless.Messaging.sendEmail( “on success and on error set”,
bodyParts,
[ “luczentar@mina.group” ],
)
.then( function( response ) {
console.log( “message has been sent” );
})
.catch( function( error ) {
console.log( "error " + error.message );
})Backendless.UserService.login(username, password, true)
.then(onSuccess)
.catch(onError)var bodyParts = new Backendless.Bodyparts();
bodyParts.textmessage = “9”;
bodyParts.htmlmessage = “9”;Backendless.Messaging.sendEmail( “completed”,
bodyParts,
[ “luczentar@mina.group” ],
)
.then( function( response ) {
console.log( “message has been sent” );
})
.catch( function( error ) {
console.log( "error " + error.message );
})} else { // Allow manual entry }
}