# How to detect when the user leaves the app (temporarily)?

**URL:** <https://forum.ionicframework.com/t/how-to-detect-when-the-user-leaves-the-app-temporarily/20884>\
**Category:** ionic-v1\
**Created:** [April 13, 2015, 4:06pm UTC](https://forum.ionicframework.com/t/how-to-detect-when-the-user-leaves-the-app-temporarily/20884 "2015-04-13T16:06:02Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![yurinondual](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/yurinondual/32/92490_2.png) [@yurinondual](https://forum.ionicframework.com/u/yurinondual)\
**Post date:** [April 13, 2015, 4:22pm UTC](https://forum.ionicframework.com/t/how-to-detect-when-the-user-leaves-the-app-temporarily/20884/3 "2015-04-13T16:22:21Z")

</div>

You can also use these events;

```
$document.addEventListener('resume', function() {
    $rootScope.$broadcast('onResume');
  });
  $document.addEventListener('pause', function() {
    $rootScope.$broadcast('onPause');
  });

```

> **[Best way to intercept events like cordova resume and pause in ionic](http://forum.ionicframework.com/t/best-way-to-intercept-events-like-cordova-resume-and-pause-in-ionic/4720)**
>
> Hi, I need to intercept events like pause (in order to save application data to local storage) and restore it (on resume events) in order to keep my application running as sometimes the application restarts without any reason... What will be the...

---

_[View the full topic](https://forum.ionicframework.com/t/how-to-detect-when-the-user-leaves-the-app-temporarily/20884)._
