I developing iOS application working with user location. The question is
"I would like to know that current location is come from Wifi or 3g or else? I would like to know the provider."
Is this possible? I googled around with no luck.
Thanks in advance.
You can't know how it is getting it, but you can know the accuracy of the locations you receive. Every CLLocation object has a horizontalAccuracy property that you can check. It will indicate the margin of error in meters. Also it has a verticalAccuracy property for 3D locations.
First if the device has GPS and you choose CLLLocationAcuracyBest or BestForNavigation, then GPS is used as Location provider all the time.
If you dont want to use that modes, you can distuniguish the location Provider by:
Only GPS delivers the attributes "course/heading" and "speed".
No other (WLAN, GSM-cell) can provice course and speed.
Altitude theoretically could be provided by GSM-Cell (or Wlan), so it could be unsafe to use the altitude as GPS identification hint. I do not recomend using altitude.
While standing still course will also be invalid even when using GPS, while speed will be a valid 0.
A further very good working solution is to use the horicontal accuracy < 40 condition.
GSM Cell will have hor. accuracy much higher than 40m, eg. 1000m.
if you have horicontal accuracy < 30 its for sure form GPS
if you have a valid course: Its for sure from GPS
if you have a valid speed: Its for sure from GPS
In all other cases its a bad position, and it usually is not necarry for further finding wheter from bad GPS or good Wlan / GSM
I ran in to the same problem like you few months ago.
I found some similar questions on stackoverflow that have the same answers like:
your device will automatically send updated location information to your app wherether it from GPS, wifi, EDGE, 3G ...
depends on your code when you init your CLLocationManager
Related
I am developing an iOS application to track user movement of the different location. I am using GPS to pull the user location[Alway from the setting location]. it works perfectly, but I am getting different location name while i am in my home.
Like in 1st bedroom you are 1503 location
and in 2nd bedroom, you are at 1702 location
how these different locations update works in background process?
It all depends of the service you are using with CoreLocation. You have here a list of the different services provided. The Standard location service (tutorial here) will be the most accurate and customizable but the less power friendly. CoreLocation often get you a location then update it to get you more and more precise location, the accuracy will also depends on the quality of your network.
You can customize the Standard location service with the following lines :
locationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters
locationManager.distanceFilter = 100.0 // In meters.
The desiredAccuracy is important.
But have you ever notice this?
When you're in a building and have WiFi turned on then CoreLocation uses WiFi to also pinpoint where you are.
How does identifying a location using WiFi work?
It's roughly something like this:
Imagine you that your building has 2 sides. Left side (1502) and right side (1702).
The left side has a wifi network named LeftSideOfBuildingWiFi
The right side has a wifi network name RightSideOfBuildingWiFi
At every moment your locationServices is turned on...Apple will capture the list of WiFi networks. It will say at 1502 the LeftSideOfBuildingWiFi has a stronger signal.
So now some other person enters the house and is connected to LeftSideOfBuildingWiFi or has stronger signal with that...Apple will conclude that you're likely at 1502.
This helps preserving the battery of the iOS device. WiFi consumes far less energy than the GPS chip itself.
The same is true if you're in the downtown. Yet if you're in the middle of nowhere in the road then it doesn't apply.
The same concept works for significant location services. They use cell-towers rather than GPS chip. Say there are 4 towers near to you and each one has a different signal strength. Likely you're closer to the one which has a stronger signal...
There is a lot of error in GPS readings. They get much less accurate when indoors, and can be off by 1000+ meters. Given that much error, it is not at all surprising that the location might geocode to different addresses when you are in different parts of a house.
I want to Know what does startmonitoringsignificantlocationchanges uses to deliver location, is it GPS or Wifi/Internet? My Understanding is it uses cellular or wifi,to know if device has moved significantly but what I don't know is, at time of picking location does it use GPS alone to pick up location.
My Findings are : I travelled 30 KM in City Train but did not get any locations in background and during this journey my Wifi and Cellular data was off. So please tell if Significant fails to provide locations based on GPS only.
Building location apps in the past, I assumed that GPS was only used when startUpdatingLocation() was called. After double-checking the docs, Apple doesn't explicitly state whether significantLocationChanges CAN use GPS, but it is a power-saving option, and their docs specify that it "requires the presence of cellular hardware", which makes me pretty certain that my assumption (and yours) are correct. I'd leave this up for a bit, in case there's a hardware expert who knows for sure. The docs you want: https://developer.apple.com/reference/corelocation/cllocationmanager
Like all location functionality, it uses a combination of cell, wifi, and GPS. Use of cell is primary. The idea is to keep use of GPS to a minimum, in order to prevent drain on the battery.
You certainly cannot expect this to work with the cell turned off; indeed, if your code properly checks significantLocationChangeMonitoringAvailable with the cell off, I would intuitively expect the answer to be false.
(Also note that you will not get any events unless you have a location manager with a delegate.)
As explained in this answer "Hows does Significant Location Change work?" (and in WWDC videos from 2013-2015) Significant location change monitoring uses a technique called Cell Tower Triangulation.
You can think of it as almost the same mechanism as GPS triangulation except that the cellular hardware will be used to gauge distance from nearby cell towers instead of firing the GPS hardware to get signals from actual satellites.
In my experience I've noticed that this method gives accuracy of approx. 1000m. It does not use the GPS hardware and hence is more battery efficient. It is good for coarse location updates. See WWDC 2013 session Harnessing iOS to Create Magic in Your Apps where the presenter makes a passing reference to this technology.
I need to allow manual positioning over a map if user location remains under a given accuracy a certain amount of time.
I need a way to test this circumstance. It's not like disable location services. Just want to have bad GPS signal (for example: horizontalAccuracy about 500 m. or so). "Unfortunately", in the place I work (my own house) I have a strong GPS signal so I can't test and fine tune the app behavior.
I wonder if there's a way to do this. Something like the network link conditioner in the developer menu on iPhone settings.
As far as I know, there's no way to do it short of writing a test class to inject location data. (I.e., there's nothing in the location simulation functionality provided by the simulator and/or debugger that will allow you to set accuracy.)
This answer to a similar question has an example of the manual-test-class-hackery way.
I am currently working on an app which requires the current region in which the user is in.The worst part is app is completely off line.
My logic :
1.Take a screen shot of the city draw squares on that.
Store square 4 points (lat long values taken with respect to map) in DB.
With the lat long values got from gps i can easily find out lat lont belongs to what reason.
I am just wondering if anybody can suggest me better idea to work my app offline.
Thank you in advance ..
You will probably find you have problems getting a location if you have no network access. iOS uses assisted-GPS, which allows the device to both lock onto GPS satellites much faster than it might otherwise take, and also pull in other data from the network to quickly determine location.
Without network access you may not get a location reported back at all, especially if the app was being used indoors (vanilla GPS reception is typically very bad without line of sight). If you do get a location it may take several minutes for an accurate enough reading to be provided.
you can use the RouteMe library which is based on OpenStreetMap. this allows to download map data in advance.
If you want to work with screenshots (from a legal source) then you use the Helmert transformation to transform between gps and picture-pixel coordinazes.
you need at least 3 points in the picture-map for which you now the lat,lon coordinates.
This is stated in CLLocationManager class reference:
When requesting high-accuracy location data, the initial event delivered by the location service may not have the accuracy you requested.
This is really affecting my app. How can I make sure that the location found is the one with the correct accuracy?
I tried to use the 4th or 5th update rather than first retrieved location but this is not a good solution. Any idea?
You should check the accuracy of the updates, CLLocation
contains a property horizontalAccuracy which you can use to check the accuracy.
When the CLLocation has an accuracy that you find accurate enough you use and ignore al others.
Als you should tel CLLocationManager your desired accuracy. To do this set the desiredAccuracy property in CLLocationManager.
I think you will have to live with that. That's how Apple implemented it. Getting a fine grained position takes time, just think about how long any windshield-mounted GPS devices in cars take to fix up their position.
So instead of letting your application wait for a longer time, they provide with what accuracy is available almost immediately, based on cell-towers and WiFi hotspots in the vicinity. Only when there has been a more reliable GPS fix will they call into your app again and let you know.
In the end, it is just a question of where the waiting for the fine-grained position is: In your app, where you have the chance of doing something with the more coarse-grained data you get quickly, or in their framework with no chance for apps to do anything useful in the meantime. I think, letting you decide is the better choice.
Depending on the type of app, you could have a map that automatically zooms in deeper as soon as better position data comes in, draw a smaller circle around the position you are expecting etc. For the end user, nothing's worse than waiting without getting any feedback. So even though this is probably not the answer you would have liked, I advise to make the best of it from a user's perspective.