First off, let me state that I am very new to iOS and Objective-C within about the last 3 months. Being transitioned to it from doing mainly Server Administration and Web App Development at work.
We are building a location based app, which relies on near perfect locations. Currently, we have a CLLocationSingleton that is called every 2 minutes. The purpose of the CoreLocationSingleton is to get the users current location, and update it using the API i built for our database.
I then have, in a controller another CLLocation delegate added directly into a view controller to determine distance from a location.
What I need to know are best practices, and practical ways of going about what we need to do.
A user checks into the current location, and we obtain coordinates with this:
RADIUS: 49.913028 LATITUDE: 32.707851 LONGITUDE: -117.148989When the user leaves the location and is
radius+20away, it sends the user an alert.. This currently fires whenever the user moves 10 meters... The current code, isn't explicitly told to run in the background -- so unless that's automatic it doesn't ( though it probably should).A user can create a region to monitor for their arrival:
RADIUS: 99.826145 LATITUDE: 32.707643 LONGITUDE: -117.154925When the user enters this location at a distance less than 99 meters, it should send them an alert (
UILocalNotification) which if in foreground can be changed toUIAlertViewusing the didReceiveLocalNotification method.
For the purposes of this app, being that we want very exact locations, GPS is mandatory. With the limitations of DidExitRegion and DidEnterRegion in the foreground ( 200meters ), that doesn't necessarily fit with our needs. Not sure if DidEnterRegion has better accuracy than DidExitRegion, but am willing to try that out.
So what are your thoughts on ways to go about this. I was thinking about creating 2 singletons for the CLLocationManager -- one to handle things in the foreground, and one to handle things in the background. With only 1 running at a time. Switching them out as needed, but being that we also want to maximize battery life, not sure this is a plausible way of making it. I thought about using the background refresh, and I found a little test app to do this -- but the problem I have with that test app, it runs for 10 seconds every minute, and stops working after about an hour. Again not looking for a specific how-to on this, just general best practices and practical ways of doing this..
Aucun commentaire:
Enregistrer un commentaire