startUpdatinLocation Frequency

Hi

I’m developing an app that requires to start updating location when the user is not in move. I declared a variable which start counting when startUpdatingLocation fires. When the counter reaches its final number I fire a method to collect data and push it to Firestone. Also I send a notification to the user. My issue is, since the startUpdatingLocation property request the location of the user twice per second, my data is uploading twice to Firestone and the notification is sent twice as well. Is there any method where can I change the frequency of getting the location from twice per second to one per second?

I’ll really appreciate your help on this

I don’t recall a way to throttle the frequency of location updates that we get from the location manager, but if you’re tracking user location when the user is stationary (not moving), then I would assume that the location you acquire twice have the same coordinates. If that is the case, you can simply store a reference to the latest location data tracked in a variable, and compare it to the latest reported. If it is the same (equal), then you don’t need to resend that to Firebase.

It’s great to know that you are being transparent by sending notifications to the user when location data is collected and stored in Firebase. Tracking location and storing it in a third party like Firebase has privacy concerns from a user perspective. So make sure to review the App Store review guidelines, and the App Store app privacy guide should you choose to publish your app in the near future.

1 Like

Hi Joash, thanks a lot for you reply. I had tried that as well with no results. What I did was assigning a unique id to the notification instead of assigning an UUID().uuidstring. That made the notification be sent only once instead of twice. Also I divided by two the property collected values and used merge when saving the data into the database

1 Like