Cerrar aplicaciones con react native [ESP- ENG]

avatar

Este tipo de funcionalidades es algo que se me ha solicitado durante el desarrollo de algunas aplicaciones y por lo general se puede resolver de diferentes maneras.
En algunos casos lo que se hace es redireccionar el usuario a la pantalla de inicio y bloquear cualquier tipo de acceso a otra pantalla pero es bueno saber que existe una función para cerrar por completo la aplicación.

This type of functionality is something I've been asked for during the development of some apps, and it can usually be solved in several ways. In some cases, it redirects the user to the home screen and blocks any access to other screens, but it's good to know that there's a function to completely close the app.
![cerrar2.jpg]()
Esta función no ejerce un control preciso y total sobre encierra la aplicación sino que simula hacer un cierre forzoso pero no borra los datos previamente utilizados en la aplicación. Cuando se utiliza esta función lo que se debe hacer es asegurarse de que todo aquel dato que se utilizó entre la aplicación se restablezca por completo antes de ejecutar la función que la cierra.
This function doesn't exercise precise and complete control over closing the application. Instead, it simulates a forced shutdown without erasing previously used data. When using this function, you should ensure that all data used during the application is completely restored before executing the function that closes it.
![cerrar.jpg]() Sí mucha más vueltas que dar es relativamente sencillo utilizar requiere prácticamente una línea de código y mostraré cómo se ve visualmente en la aplicación y en el código.
Yes, much more to go around, it is relatively easy to use, it requires practically one line of code and I will show how it looks visually in the application and in the code.
![cerrar1.jpg]()

En este caso implemente un modal el cual se muestra cuando uno se encuentra en la pantalla de inicio y quiere volver hacia atrás. Este modal cuenta con dos opciones Y si el usuario acepta cerrar la aplicación primero se ejecutará el código que cierra el modal y luego la función que cierra por completo la aplicación para evitar que si el usuario vuelve a abrir la aplicación aparezca ese mismo modal visible.

In this case, I implemented a modal that displays when you're on the home screen and want to go back. This modal has two options: If the user agrees to close the app, the code that closes the modal will be executed first, followed by the function that completely closes the app. This prevents the same modal from appearing visible if the user reopens the app.


0
0
0.000
1 comments
avatar

Thanks for your contribution to the STEMsocial community. Feel free to join us on discord to get to know the rest of us!

Please consider delegating to the @stemsocial account (85% of the curation rewards are returned).

You may also include @stemsocial as a beneficiary of the rewards of this post to get a stronger support. 
 

0
0
0.000