Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70612

How to handle iddle app

$
0
0

@pierro wrote:

Hi all,

I'm trying to handle when my app goes background.

The main purpose is to reload the whole app if the user comes after more than 30seconds with the app in background for example.

I am using $ionicPlatform.on('resume'... for that.
It works well when I put no timer. Like the user leaves the app with home button on android, and when he gets back the app just fully reload with the following code:

$ionicPlatform.on('resume',function() {
location.href = location.origin;
});

However, when I try to add a timer to make sure 30 seconds have passed, it no longer fire.
Here is my code, I am using $ionicPlatform.on('pause' ...:

var timerOut = false;
	$ionicPlatform.on('pause',function() {
		$timeout(function(){
			timerOut = true;
			alert("timeout happened!");
		},30000)
	});
	
	$ionicPlatform.on('resume',function() {
		if (timerOut) {
			location.href = location.origin;
		}
	});

This is in my app.js, after ionicPlatform.ready

Did anyone manage to handle it?

Thanks

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 70612

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>