GPS signal lost warning notification - iphone

Can anyone tell how to show an error message when GPS signal is not available on iphone.
And the lat,lon label remains shows the previous reading where the signal is lost. Please anyone guide me.
Thanks prior.....

Implement the CLLocationManagerDelegate protocol method locationManager:didFailWithError:.
Here's a quote from the documentation:
Discussion
Implementation of this
method is optional. You should
implement this method, however.
If the location service is unable to
retrieve a location fix right away, it
reports a kCLErrorLocationUnknown
error and keeps trying. In such a
situation, you can simply ignore the
error and wait for a new event.
To keep the values you should buffer them in a property and only update them when locationManager:didUpdateToLocation:fromLocation: fires.

One thing that could happen, when having and then losing "true" GPS, is that Core Location will fall back to cell tower triangulation or wifi sniffing.
The only way you'd know that had happened is a sudden increase in the .horizontalAccuracy value of the CLLocation objects you get in your didUpdateToLocation: method.

Related

Is there any event that catches when the user turns the corner?

I'm writing a program on WatchKit SDK. My aim is to generate a route between user's current location and another point. And I would like to catch a moment when the user should turn the corner. At the moment I wonder, what is a proper framework to use because in fact I do not need to display the map but do need to be able to build the route and catch the turns. Could you advice the proper way to do it?
If I understand your question correctly, you will need to track the users GPS coordinate in your WatchKit extension running on their iPhone. You will need to use the course and coordinate properties on the CLLocation object to determine when you are getting close or at the correct corner and then respond accordingly.
Here is some more info on tracking GPS coordinates in a WatchKit extension How to calculate current location in WatchKit extension

didUpdateLocations will call on stable phone or now?

I want to know that locationManager:didUpdateLocations: will call when my phone is in stable position?
In my case its not calling when i put my phone on one place.
I Placed my phone from one location to other location within my room but still its not calling.
Can anyone tell me that when it will call.
When i change location using xcode then its always calling.
I used
self.locMgr.desiredAccuracy=kCLLocationAccuracyBest;
Okay, so you say within the simulator it works, but it does not work when you run your program on the actual iPhone device, right?
You were correct in setting the accuracy. This should work actually unless you have switched off the location update in general for your iPhone (settings under Privacy->Location Services).
If this is all working you maybe want to paste more of your code, but again, I think if it works under the simulator it should work on the device.
The location manager calls for location updates on the accuracy you set. It will not get called on a stable location more than once. you can use distance filter to call it after a certain distance.
self.locationManager.desiredAccuracy = kCLLocationAccuracyBest;
self.locationManager.distanceFilter = 10; //meters
For updating it on the same location you will have to use a timer which will call for updating after every desired interval.
Probably it depends on the accuracy you set to the locationManager.
1).. Cell Radio 2).. WiFi Map, 3).. GPS
If you set best as accuracy the location manager will continue to
check you position, if the location with better accuracy is out of the
range of the distance filter the delegate method will be called again.
GPS is not exact.some time if you move about a feet and still it will
not update. or some time you didn't moved at all and it will update.
Stop testing GPS and Location Services inside! Go outside and move around to test it.
Make sure that you set the delegate for the Location Manager & also
make sure you get the permission for using "User's Current Location."

delegate method for CMMotionManager

I just want to know that when we call the method of startGyroUpdates with CMMotionManager and fix some updateInterval say to 1.0/60.0 , then is there any delegate method that we have to implement where we can get the gyro updates. If not then where/how we can get the gyro-updates.
Also if there is some useful code snippet to find out device change in position i-e if the device is moved up or down from some reference point.
Documentation says:
startGyroUpdates
Starts gyroscope updates without a handler.
- (void)startGyroUpdates
Discussion
You can get the latest gyroscope data through the gyroData property. You must call stopGyroUpdates when you no longer want your application to process gyroscope updates.
Availability
Available in iOS 4.0 and later.
See Also
– startGyroUpdatesToQueue:withHandler:
Declared In
CMMotionManager.h
Adding to xs2bush's correct answer: See the documentation links in Simple iPhone motion detect for more information.
Regarding the second point moved from some reference point, definitely not. At the moment there is no way at all to determine displacement with an acceptable precision. There are several questions and discussions about this like
Getting displacement from accelerometer data with Core Motion or
Measuring time the vehicle takes to accelerate in iPhone (I don't believe the 3% ;-)

locationManager:didUpdateToLocation:fromLocation not getting called for Significant Location Changes Monitoring

I implemented background location tracking using standard location services, and it works fine. However, since this implementation uses a lot of power, I decided to switch to significant location changes monitoring. Basically, I just changed all the calls to startUpdatingLocation to startMonitoringSignificantLocationChanges and reused the CLLocationManagerDelegate methods I have implemented before.
The problem is that after switching to significant location changes monitoring, the delegate method locationManager:didUpdateToLocation:fromLocation only gets called once when I start monitoring, and is never called again afterwards. I have moved around the phone for a couple of kilometers, and tried riding a train with it, but still the method never gets called. Am I missing something here? Are there settings I need to enable or special code I need to write in order for this to work?
Thanks!
The significant location change requires cell phone towers in order to operate. If you don't have cell phone reception you will not get any results. You can also call CLLocationManager's significantLocationChangeMonitoringAvailable method to see if it is available.

Executing code in background

I have a application that periodically (via an NSTimer) asks for the users location using locationManager:startUpdatingLocation I want the locationManager to run in the background so have entered "UIBackgroundModes = location" in the info.plist file.
My question is I am not seeing the results I expected, am I right in thinking that when I press the home button the application delegate calls "applicationDidEnterBackground" but although locationManager is allowed to continue my NSTimer is getting suspended (and as a consequence its not calling startUpdatingLocation to periodically query the devices position). Any ideas / solutions would be much appreciated ...
Gary.
All NSTimers are invalidated when entering the background. You need check via the CLLocationManager for any changes.
Just keep the startUpdateLocation running, you delegate will receive any major changes of the location.
When running in the background, you will only receive location changes based on cell towers.
If you read the documentation for -applicationDidEnterBackground: you'll find that yes, your timers are invalidated. Furthermore, the iOS Application Programming Guide tells you exactly how to track location from the background.