# Is there an App Close Event that can trigger some action?

**URL:** https://community.thunkable.com/t/is-there-an-app-close-event-that-can-trigger-some-action/2004758
**Category:** Feature Requests
**Created:** [August 18, 2022, 1:29pm UTC](https://community.thunkable.com/t/is-there-an-app-close-event-that-can-trigger-some-action/2004758 "2022-08-18T13:29:02Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![tonyb2](https://avatars.discourse-cdn.com/v4/letter/t/c67d28/32.png) [@tonyb2](https://community.thunkable.com/u/tonyb2)
#### Post date: [August 18, 2022, 1:29pm UTC](https://community.thunkable.com/t/is-there-an-app-close-event-that-can-trigger-some-action/2004758/1 "2022-08-18T13:29:02Z")

</div>

I need to detect an App Close event (Android).  
Is this possible? And if not can it be added?  
I need to be able to Log the User Out of a Backendless DB session if they close the App without choosing the Logout option in the App.  
Failing this I end up with lots of issues if they have too many current logins.  
Setting a Session timeout in Backendless doesn’t seem to have the desired effect.  
I can also increase the limit of concurrent logins allowed but they run out eventually too!  
Solutions anyone?

---

<div class="post-metadata">

### Author: ![jared](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jared/32/138473_2.png) [@jared](https://community.thunkable.com/u/jared)
#### Post date: [August 18, 2022, 4:33pm UTC](https://community.thunkable.com/t/is-there-an-app-close-event-that-can-trigger-some-action/2004758/2 "2022-08-18T16:33:23Z")

</div>

if they close the app without logging out, you _could_ log out your user. you could also store the token in an app variable. require a call using the token to allow the user to pass beyond the sign in screen. You might be able to create some kind of backend flow that can recognize when a user hasn’t had some in app action and invalidate their token that way.

what kind of issues are you running into with too many concurrent logins?

I use an app that always makes me log in if i’ve even had it in the background for a while. I think this is done by regularly polling your backend to keep the front “alive” so to speak. you could set a timer that if it ever hits 0 always redirects the user to the sign-in screen. you could reset that timer when the app is open by calling your backend.

---

<div class="post-metadata">

### Author: ![zander](https://avatars.discourse-cdn.com/v4/letter/z/ecb155/32.png) [@zander](https://community.thunkable.com/u/zander)
#### Post date: [August 18, 2022, 5:19pm UTC](https://community.thunkable.com/t/is-there-an-app-close-event-that-can-trigger-some-action/2004758/3 "2022-08-18T17:19:26Z")

</div>

I use refresh tokens, if they have expired they are directed back to the log in screen

Edit: scroll down to the sign in with email and password, it returns some info that can be used to check

> **[Using the REST API  |  Identity Platform Documentation...](https://cloud.google.com/identity-platform/docs/use-rest-api)**

---

<div class="post-metadata">

### Author: ![tonyb2](https://avatars.discourse-cdn.com/v4/letter/t/c67d28/32.png) [@tonyb2](https://community.thunkable.com/u/tonyb2)
#### Post date: [August 19, 2022, 5:28am UTC](https://community.thunkable.com/t/is-there-an-app-close-event-that-can-trigger-some-action/2004758/4 "2022-08-19T05:28:42Z")

</div>

Thanks guys.  
I’m using Backendless as a DB and it also has a session based token for the user.  
I did lower the session timeout but it didn’t seem to do anything.  
So whilst testing the login / logout process I quickly ran into trouble.  
It seems that the session timeout setting is finally being invoked and all is ok for now.

---

<div class="post-metadata">

### Author: ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)
#### Post date: [August 19, 2022, 7:07am UTC](https://community.thunkable.com/t/is-there-an-app-close-event-that-can-trigger-some-action/2004758/5 "2022-08-19T07:07:22Z")

</div>

Another way that is specific to Android is to use the `back button pressed` in the screen and use an alert or whatever process you want to close the active session.

---

<div class="post-metadata">

### Author: ![ioannis](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ioannis/32/146956_2.png) [@ioannis](https://community.thunkable.com/u/ioannis)
#### Post date: [November 8, 2024, 1:12pm UTC](https://community.thunkable.com/t/is-there-an-app-close-event-that-can-trigger-some-action/2004758/6 "2024-11-08T13:12:57Z")

</div>


