[RESOLVED] Requesting Users Location


#1

Good afternoon everyone!

I have a few pages in my iOS app that requires the users location. I thought there would be a way to request the users location on the app launched lifecycle event but that requires either a device or page variable. While I can create a page variable for the location, I can’t create a device variable to used throughout each page. I don’t want to request authorization on every page. That seems redundant.

Do I create a page variable on the Home page of the app for the location manager, request auth on the homepage and then pass that to every page by a page variable on each page and then requesting to update the location?

Thanks in advance. Just want to make sure my workflow is correct.


#2

Hi Matt,

What I’ve noticed when working with location needs on multiple pages is that when you go to and leave a page you’ll need to use Start Updating and Stop Updating location actions. It’s not the best solution but the turning on/off with each page seems to help this issue. The Authorization prompt is only given to the user one time and after that it is redundant.

In an custom coded app, you would establish an external controller to manage the state and location tracking separately from pages but that’s not possible in Dropsource in how our editor builds page UI’s.


#3

Hey @wade, thanks for the update on this. So if I prompt the user on my home page for their authorization for location then is that authorization only good for that page? When a user navigates away from that page, is the location services then reset back to off or not allowed for this particular app?


#4

Ah, I probably explained that poorly. The Authorization request is app-wide. Once they give the app permission for location data, you can Start Updating and Stop Updating location data anywhere. I just mean that the "start updating locations will end when you move to a new page.

So what I see work well is that before moving to a new page, you’ll Stop Updating location and then if the new page you go to needs fresh location information, you’ll Start Updating again and can continue to update the same Device Variable for use. Then when they leave that new page, you should do a Stop Updating once again.

Does that help?


#5

Wow! I did read that completely differently. Yes. This helps. Honestly, if I just would have tested a bit more I probably would have noticed this myself and this entire thread would have never been born. Oh well, now the forum knows and hopefully it also helped someone else. Thanks again.


#6

We are always learning. That’s part of the fun. Great work!