-3

In my app the user can book a parking space in the parking lot. I need a timer that counts the time the user parks in the parking lot. The timer should continues to run even when the device is turned off or not connected to the internet. If anyone has a solution or idea for the problem it will help me a lot, thanks in advance.

Ido
  • 9
  • 3
  • 1
    Instead of letting the timer run, just register the time at which the user enters the parking space. Then, when you need the "timer" receive the difference between now - time of arrival. – Beru Jun 17 '21 at 22:06
  • @Beru But what if the device doesn't connected to internet? – Ido Jun 17 '21 at 22:10
  • Safe the information locally and then pass it to your server once a connection is available. – Beru Jun 17 '21 at 22:14
  • @Beru What if the user trying to "cheat" the app, and delete the app? – Ido Jun 17 '21 at 22:17

1 Answers1

2

Have it save the time when the app is closed and subtract that from the current time when the app turns back on, that will give you the number of seconds that have passed between sessions which you can convert to minutes/hours/whatever.

Ryan
  • 169
  • 8
  • But what if the user delete the app, or if the time data saved on firebase what if the device is offline? – Ido Jun 17 '21 at 22:08
  • 2
    @ido if the user deletes the app while their car is parked then that's on them :/ – Ryan Jun 17 '21 at 22:11
  • 1
    @Ido Then use a server of some type to record the timestamps. – Basil Bourque Jun 17 '21 at 22:11
  • @ido oh well you didn't say that it was responsible for payment, I thought it was just to alert someone when their time was up. If its affiliated with the lot then the best way to go about it is have the lot issue a number when they park, and then the number is tied to how long they've been there – Ryan Jun 17 '21 at 22:17
  • @ido yeah, if the app is the lot's app then you use a server to keep track of it – Ryan Jun 17 '21 at 22:22
  • @ido they'd have a server with a code for each parking instance and start date. When the customer showed up to get their car they'd check in with their parking code and then end date would save. at that time the time is determined which translates to parking fee – Ryan Jun 17 '21 at 22:24
  • @Ryan oh i understand, you gave me some ideas. thank you very much. <3 – Ido Jun 17 '21 at 22:25
  • @no problem, hope it works out. Accept the answer if you're moving on so people know it's closed. – Ryan Jun 17 '21 at 22:26