Location updates issue for iOS 7 - ios

I'm developing an iOS map application, so it's essential to receive location data consistently.
What is happening now is that the system allows the to app load the map and that's it!
The location getting instruction seems to freeze, even the network traffic indicator at the top bar disappears. Simply when I go to Settings->Privacy->Location Updates, switch off location updates for my app and then switch it back on. The map loads the current location.
What could be the possible causes to this?, please advice.

Use:
[_mapView setUserTrackingMode:MKUserTrackingModeFollow animated:YES];
This will smoothly follow the users current location. If you drag the map it will even set the tracking mode back to MKUserTrackingModeNone which is usually the behaviour you want.

Related

Using geolocation.watchPosition() in mobile safari using location services

The output geo coordinates are only accurate on first load, the problem is when the iPhone screen times out and the locations services also timeout. And if I open safari again the geo coordinates are off by 100's of meters. The same thing happens if I push safari app to background. The problem is fixed if I reload the safari tab requesting geolocation or if I clear safari app cache and open up safari again. Why is this happening? My use case involves showing the user an arrow that guides to destination. Thus it is likely the phone times out occasionally for user that leads to location services timeout. iOS chrome does not mimic this behavior and work as expected i.e geo coordinates are always accurate event after tab in focus and /or screen timeout.
I don't know why this happens exactly, but it's happening to me too. I was able to get around the issue by using window.setInterval to call a function every 5 seconds or so that checks whether the location has been updated. If it hasn't, then the function stops and restarts the geolocation watch.
The restarting of the geolocation watch has the same effect as reloading the page, i.e. the accuracy becomes much better again, and location updates resume. Hope that helps!

IOS side loaded App changing current location

Trying to develop my first application which will just be side loaded to my device. I am unsure if I can even do what I'm looking for; I'm trying to change the current location on my device via my application. I know this is done with the Xcode debugger but can it be done solely on the application with no connection to the computer? Basically I have a few buttons, each one I want to change the location to somewhere different. Do I just code the coordinates to set with the button and thats all? Will this show on my maps application and such? Thanks.
What you ask is not possible. The GPS hardware is what reports location to the phone. Xcode is able to do this because it is reporting location to the simulator, which has no GPS hardware on its own

Google maps ios api using user's location in fitbounds

I am trying to set a bounds between the users location and a selected marker. I can set everything up properly but when I try to use the users location (mapView_.myLocation.coordinate) it says the lat and long are both 0. I did create a button to center the camera on the users location and it gets the lat and long just fine. Does not make any sense to me. Also I don't have a device set up to test so I am using xcodes iOS simulator with a location put into the simulator (is that where my problem is?). Any ideas?
Are you trying to access myLocation.coordinate from loadView or similar, ie when the app first starts up?
Generally when enabling location services the app doesn't receive a location update immediately, it comes through after some delay. So it's possible that myLocation.coordinate won't be valid in loadView, but will have a value set some time later (which is why it works with your button).
You could perhaps listen for changes to myLocation, and then set your bounds when it changes to something.

iOS : Detect user location when App is back from Background

I have a MKMapView & I use it to display user's current location. It works normal when I first load it in the App. But when I press Home button to put the App to background & call it back from background, the map prompts it is unable to find the user's location.
I was thinking is the MKMapView takes time to search for user's location, and when I call it back from background, it does not have enough time to load the location service ?
iOS5 SDK, xCode 4.3 is used.
If I understand your question correctly, your problem is that when your app resumes (becomes active), mapView.userLocation returns nil. Although I haven't tested this, I suspect it is because the mapView will need some time to relocate the user. You can get around this by adding your logic to the appropriate delegate method instead, which is - (void) mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation, if memory serves me right (you might want to verify that, though).
EDIT: Make sure you test location-related code on a device, since its behaviour might differ from the simulator.

CLLocationManager don't stop

Dear fellow developers,
I am trying hard to find a solution for my problem regarfing CLLocationManager.
I use a CLLocationManager instance in my Application. If the user selects the Home button on the device or terminates the application I want the location services to stop.
Therefor I call [self.locationManager stopUpdatingLocation]; - But this somehow doesn't work. The application enters the background and the small location arrow in the upper right corner of the status bar don't disappear. Even if I add [self.locationManager release] or self.locationManager.delegate = nil; - the location tracking don't stop :-/
It only disappears if I go to my device settings and switch off location services for the app. Whenever I switch back to location service enabled I immediately get a purple colored arrow next to the switch toggle and the icon reappears in the status bar.
My question is how can I turn off location services when the app enters the background or is terminated?
Thanks a lot in advance and have a nice day :-)
Your location is disabled. The location service icon "meaning" has changed on iOS 5. Take a look at this question: https://apple.stackexchange.com/questions/27463/why-is-the-location-services-icon-always-present
I Quote the answer:
It's a new feature in ios 5 called "region Monitoring"
The reason it's active even if the app is closed is that this feature
runs in iOS 5 core and notifies all apps that are registered when they
have entered or left a specific geo-fence.
Reminders does that when you use a location based reminder.
Although the location icon appears at all time. This actually has very
minimal impact on the battery due to apple really optimizing this
feature by using cell and wifi mostly.
Your app is working ok. The system behaviour is the one who changed.
You do it the right way. When entering background, it's ok if some delegate methods are called for some seconds. That should stop.
Where do you stop the location updates ? Are you sure it is triggered ? If yes, are your delegate method called even if the visual indicators tell something else ?
Are you sure you don't trigger a method that reactivate the location update after you have stopped it (because for example you can receive some updates even after stopped).
For instance if you started monitoring a significant location change, then you should unsubscribe from it with the corresponding pair method. If you are using region enter, then until you unsubscribe, the system will notify your delegates.

Resources