shwetha
shwetha

Reputation: 11

How to implement idle timeout in Nativescript android application

I am building a Finacial application in Nativescript angular. I need some references like if the app is opened and running in the background after the set of some idle timeout it should redirect to the page which we specified. I couldn't get the proper reference in Nativescript can anyone please add a solution for the idle timeout. I have checked Nativescript extended activity but couldn't get properly

Upvotes: 1

Views: 362

Answers (1)

Jscti
Jscti

Reputation: 14440

You should start by reading the documentation. What you need is Lifecycle hooks.

Read : https://docs.nativescript.org/angular/core-concepts/application-lifecycle#use-application-events

applicationOn(suspendEvent, (args: ApplicationEventData) => {
    setTimeout(() => {
        // do what you want after a certain amouont of time
        // don't
    }, 5000); 
});

or

applicationOn(resumeEvent, (args: ApplicationEventData) => {
    // compare current datetime with the last datetime saved in suspendEvent event
});

Don't forget your app can be force-closed, so you have to handle this depending on your needs

Upvotes: 1

Related Questions