Reputation: 135
I want to exit the entire application in on Tap() of logout button in nativescript app. I referred the use of application events in below link. https://docs.nativescript.org/core-concepts/application-lifecycle
I want more idea on this?
Thanks in advance..
Upvotes: 3
Views: 6460
Reputation: 59
npm i nativescript-exit
import { exit } from "nativescript-exit";
exit();
import { exit } from "nativescript-exit";
// to instal 'nativescript-exit' run in root folder(where node_modules are):
// npm i nativescript-exit
public logOut(): void {
exit(); // will close application
}
<Button text="Log out" (tap)="logOut()"></Button>
Upvotes: 2
Reputation: 3550
I don't advocate exiting your app programmatically, but it can be done with a bit of code.
On iOS you'd do:
exit(0)
And on Android:
android.os.Process.killProcess(android.os.Process.myPid());
There's a plugin making it even easier for you: https://github.com/dvabuzyarov/nativescript-exit
Upvotes: 5