I want to do the following.
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.