Forum Academy Marketplace Showcase Pricing Features

How to check did the user close the app page?

So I’m planning an on-demand platform app and I need to check is the expert (or driver like in uber) is online in order for customers to see what experts are online.

I have a is online? on the user DB and when the header is loaded it would set the field to “yes”. However, I’m unable to make it go to “No” When the user closes the app page, is there any method/plugin to detect did the user close the web app page and is now not online?

What you can do is try to run a workflow every 5 seconds to check if your experts are logged in.

There are some plugins for this and also some videos in YouTube.

I don’t think a user would log out when they close their bubble webpage/apps.

Also, the online/offline plugin that I tried can’t really work as it requires me to set a timeout time when I simply want it to go offline when the page got closed

This is an interesting problem and I don’t quite know how to solve it with Bubble’s current capabilities.

But I did come across this post and a few people offered some interesting solutions. Have a look!

Thanks for the post, but the problem is that I don’t need to check is the user active or not as I would have a button for the exprts to be clicked called “available” like UBER , when they click it they would be searchable for users.

They might be inactive but they would still be available as I would send a notify sound for them to respond to accept the task or not in a specific time (just like uber), but they might somehow closed their webpage/app for some reason or want to go offline and I need to set their status to offline when they have no bubble page on their browser as I would not be able to notify they have a customer.

1 Like

Hmm, the “available” button is pretty much all you need. You can’t really predict how or when your expert is going to get a notification. For example, I have 40 chrome tabs open right now and some I haven’t used in days. So I’m technically “inactive” on those pages even though it’s still open. I don’t think closing the page should be the indicator for availability.

How about setting the user to online on page load via a custom state (isOnline = yes) that is defaulted to “no”. And then if the “I’m Available” button is clicked and the page is closed, notify them via an email from a workflow?

1 Like

Yes, it works.

Create a new column in your User’s database called “last_activity”.

When your “Expert” is loged in, he will have a workflow running every 5 seconds updating his field with the Current date/time.

General users will see only the “Exeprts” that have the field last_activity > Current Date/Time - 10 sec

Once the Expert closes the page, the workflow will stop updating his “last_activity” field and the users will stop seen he as a logged Expert.

1 Like

Thanks for the help rpetribu!

I put the 5-sec workflow on the header and it works, i’m praying that it would not overload the servers when future users joins…

Hey all,

You may also want to consider checking out this plugin just released by @BubbleSam

1 Like

Thanks @Johnny for sharing this!

Actually we have a better demo that does exactly what @warformstudios needs!

In this demo user becomes idle (inactive) after 10 seconds of inactivity. Feel free to check the editor and app workflows to see how it works! :wink: