Badoo repeat - How to determine and keep track of user's location in IOS?

I want to do the following.

  • Keep updating a user's location using Core Location and send that information to a database.

I am creating an app like badoo so I need to know where a user is located at all times to know who is near them.

I did the following:

I put the following code in applicationDidFinishLaunchWithOptions

locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
[locationManager startUpdatingLocation];

and then the following function in AppDelegate.m

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
    self.currentLocation = newLocation;

    // send location to server

    if(newLocation.horizontalAccuracy <= 100.0f) { [locationManager stopUpdatingLocation]; }

Is that the most efficient way to do it?

How then can I use the longitude and latitude details and django to be able to tell who is near a user?

Thanks for your help!


As for efficiency - it depends on what you mean. The method you describe doesn't allow the user to actually start the process of determining location - it starts when the app starts. If that is your intent, then I see this as being efficient for the user to not take the time to start it.

However, you have the code in the appdelegate file. For efficiency as to maintaining code, I would not agree to the pattern you have provided. A more efficient (in terms of development) it would be best to have a separate model handle the updates from the location manager and have the appdelegate create an instance of said model.

Sorry - can't help with django.

Need Your Help

display:table width+padding gives scrollbar

html css html5 css3

I need to give padding to the parent div which has display:table but when it has width:100% then adding padding causes horizontal scroll bar so how to make the parent div full width to the browser ...

Alternate list elements float with css

html css

I have a page where i list messages that is loaded from a database with ajax.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.