I'm trying that when the invalid api key message appears in my prueba.js file, the application shows the log out message but it doesn't. I am also printing the api key message via a console.log
Titanium version 12.1.2.GA
// Importar el módulo FileSystem de Titanium
var FileSystem = require('Ti.Filesystem');
// Ruta del archivo prueba.js
var filePath = 'prueba.js';
// Leer el contenido del archivo prueba.js
var file = FileSystem.getFile(Ti.Filesystem.resourcesDirectory, filePath);
var contents = file.read().text;
// Buscar el error "API KEY INVALID AUTH" en el contenido
if (contents.includes("API KEY INVALID AUTH")) {
// Realizar el log out del usuario
logout();
} else {
// Continuar con la lógica normal de la aplicación
console.log("El contenido de prueba.js no contiene el error 'API KEY INVALID AUTH'.");
}
// Función para realizar el log out del usuario
function logout() {
// Aquí puedes agregar el código necesario para cerrar la sesión del usuario
// Por ejemplo, puedes borrar las credenciales de autenticación almacenadas o redirigir al usuario a la pantalla de inicio de sesión
console.log("Se ha realizado el log out del usuario.");
}