CLLocationManager Not getting Location Accuracy In Cellular Network (3G) - ios

I am Having a problem In Location Accuracy Using Cellular Network.
Following are the My issues
Sometimes Location accuracy is very perfect in Cellular Networks(3G)
Sometimes Location Accuracy is Not getting perfectly Its one mile difference.
For WiFi Its working Very Perfectly.
Following are My code
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation;
[locationManager startUpdatingLocation];
Please what is the problem for my code.

Cellular network location gives an approximate area were the phone existing. It is based on the service providers tower.So i recommend using gps location tracking so that you get the exact longitude and latitude of your phone.
Longitude and latitude can be used to find more details about the location like place,weather etc..
Please refer this

This is because you can't force the device the location trough satellite (3G or 4G)
You (the app) can only access the location the device gets (And if it have permission).
When you have highest accuracy kCLLocationAccuracyBestForNavigation it will try to get the most accuracy it can get (First GPS, then triangulation/network + aditional sensor data) (Not recommended, this is only for "navigation" it consumes too much energy and assumes it is plugged in).
For this please refer to the Core Location Constants Reference
If you are outdoors you may not have exact location at first, it may take some time to get the best location available to the phone.
Please reffer to the documentation of CLLocationManager desiredAccuracy
When requesting high-accuracy location data, the initial event
delivered by the location service may not have the accuracy you
requested. The location service delivers the initial event as quickly
as possible. It then continues to determine the location with the
accuracy you requested and delivers additional events, as necessary,
when that data is available.

Related

how to get the location with the CLLocationManager every 10 secondes?

I want to get the different locations of the users in order to display him the trips he did. But in order to save my user's battery, I want to get his location just every 10 seconds with my CLLocation manager.
I first thought about not implementing the 10 seconds interval and get the user's location every time he move with the didUpdateLocations of the CLLocationManager, but when I simulate a drive I get new location every second and I think this is really bad for the battery, am I right ?
Do not try to second guess the location manager. Your job is to set its properties appropriately, such as distanceFilter, desiredAccuracy and activityType. Apple will use every trick in the book to keep battery usage reasonable given your settings. As the docs tell you:
Core Location manages power aggressively by turning off hardware when it is not needed. For example, setting the desired accuracy for location events to one kilometer gives the location manager the flexibility to turn off GPS hardware and rely solely on the WiFi or cell radios, which can lead to significant power savings.
If the goal is track location in the background, there are special modes for that, which save even more.
Check location every 10 second a lot frequent, it will be drain user's battery too fast.
If you would save battery, you should learn apple guide about location manager.
You need use distanceFilter and desiredAccuracy
Base guide CLLocationManager
Energy Efficiency Guide for iOS Apps
Location Awareness Programming Guide - Tips for Conserving Battery Power
Update
Also you can check how fast user moving CLLocation have speed and adjust activityType

How much does pausesLocationUpdatesAutomatically affect iBeacon detection?

Working on Apple's iBeacons, here is some code that I use to initialise CLLocationManager and start monitoring for beacon regions:
self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.pausesLocationUpdatesAutomatically = false;
self.locationManager.allowsBackgroundLocationUpdates = true;
self.locationManager.delegate = self;
How much does pausesLocationUpdatesAutomatically play a part in region monitoring?
The official documentation says:
A Boolean value indicating whether the location manager object may
pause location updates.
However the "Getting Started with iBeacons" official guide does not mention this. Plus it was last updated in 2014 and I haven't found any more on this.
How does this affect battery life?
How does this affect the iBeacon region detection?
Location updates and beacon detection are not related.
iBeacon detection uses the Bluetooth chipset and doesn't provide you with a location as such. It just tells you that you entered (or exited) a CLBeaconRegion.
CLCircularRegion detection is different; this relies on determining the user's latitude and longitude; either by GPS or WiFi. GPS has a significant impact on battery life.
So, the short answer is that pausesLocationUpdatesAutomatically shouldn't have any impact on beacon detection.
If you check full description for pausesLocationUpdatesAutomatically in documentation, you'll see explanation:
Allowing the location manager to pause updates can improve battery
life on the target device without sacrificing location data. When this
property is set to YES, the location manager pauses updates (and
powers down the appropriate hardware) at times when the location data
is unlikely to change. For example, if the user stops for food while
using a navigation app, the location manager might pause updates for a
period of time. You can help the determination of when to pause
location updates by assigning a value to the activityType property.
And for activityType:
The location manager uses the information in this property as a cue to
determine when location updates may be automatically paused. Pausing
updates gives the system the opportunity to save power in situations
where the user's location is not likely to be changing. For example,
if the activity type is CLActivityTypeAutomotiveNavigation and no
location changes have occurred recently, the radios might be powered
down until movement is detected again.
If you turn on pausesLocationUpdatesAutomatically it'll start to monitor significant location changes and save battery since it is not using GPS so often.
Region detection, in such case, will occur when there is significant change, so this check will be performed less often, tricky part here is how much is region detection important for you - if you decide to save battery will significant change detection be ok for region detection.
I hope this helps.

How to get the location provider name in iOS?

In Android whenever you get location object you could call "location.getProvider" on the instance to get value like "wifi". Is there something similar in iOS (CLLocation)?
The Location Awareness Programming Guide says:
The [CoreLocation] framework uses information obtained from the built-in cellular, Wi-Fi, or GPS hardware to triangulate a location fix for the device. It reports that location to your code and, depending on how you configure the service, also provides periodic updates as it receives new or improved data
Having said that, you do not have access to how precisely the CLLocationManager determined your location (other than, if you used significant change, that it probably used cell towers). You theoretically could use Reachability to see if you have Wi-Fi availability, but you have no assurances as to what mix of GPS, cellular, and Wi-Fi it used to get your location (even if you happen to have WiFi connection).
What you do have is horizontalAccuracy, which tells you approximately how accurate the location you received is. From a user's perspective, that's probably a more important piece of information.
There isn't a concept of what system provided you with the location on iOS. What you can do is check what the accuracy of the location is. Based on how precise the location is, you can probably surmise if the location was provided by a GPS signal.
The reason this isn't given is that iOS will provide you with an initial location which won't be very accurate (likely based on geo-ip or cell triangulation) and then update the location with more and more precise coordinates if GPS is available.
If your application requires the accuracy provided by a GPS chip, you can add UIRequiredDeviceCapabilities = gps to your Info.plist.

Getting GPS satellites and atomic clock time stamp in iOS

Is it possible to get the GPS atomic clock time stamp in iOS?
Also, is it possible to see which satellites were used in a certain sample?
As far as I know GPS receivers get this info, but I didn't find any way to get access to it.
iOS is not providing any such public APIs to access those details.
As per Apple documents:
A location manager object provides support for the following
location-related activities:
Tracking large or small changes in the user’s current location with a
configurable degree of accuracy.
Reporting heading changes from the onboard compass. (iOS only)
Monitoring distinct regions of interest and generating location events
when the user enters or leaves those regions.
Deferring the delivery of location updates while the app is in the
background. (iOS only)
Reporting the range to nearby beacons.
Nowhere it says about GPS atomic clock time stamp.
This works to get the GPS time:
#import <CoreLocation/CoreLocation.h>
CLLocation* gps = [[CLLocation alloc]
initWithLatitude:(CLLocationDegrees) 0.0
longitude:(CLLocationDegrees) 0.0];
NSDate* now = gps.timestamp;
I haven't seen anything that would lead me to believe you could get the satellite numbers through the official API. Perhaps through unpublished methods? But fwiw that would exclude your app from the App Store.

Determining iOS Location Services' mode of update

I'm building a little prototype app to test Location Services. My app uses both -startUpdatingLocation and -startMonitoringSignificantLocationChanges (for background processing).
In both cases, I'm trying to send a json object to a server with the location data I get, but I'd like to be able to also send some sort of identifier so I can determine which mode of location service was used to acquire the data (GPS, wifi, tower or at least if it was through one of the two services above.
I'm setting up my CLLocationManager in the AppDelegate if that makes any difference.
Thanks
The sources that CLLocationManager uses are not provided. However, you can determine whether GPS is allowed to turn off by setting the desiredAccuracy property. As the documentation notes, an accuracy of 1 kilometer may have the GPS turn off.
For example, setting the desired accuracy for location events to one kilometer gives the location manager the flexibility to turn off GPS hardware and rely solely on the WiFi or cell radios. Turning off GPS hardware can lead to significant power savings.
You don't exactly control the GPS because other apps may be requesting a greater accuracy in the background.
You can roughly guess what was used for determining your location by examining your CLLocation object. Each CLLocation object has a property called horizontalAccuracy. This value is measured in meters. If it is less than 1 kilometer then GPS was probably used.

Resources