How to get current location - iphone

I know how can I fetch current location but I want does ios support different api for mobile network and wifi network for getting of current location or same api will use for both?
Does ios current location api will take care of both network connection?
Reference from
https://developer.apple.com/library/ios/DOCUMENTATION/CoreLocation/Reference/CLLocationManager_Class/CLLocationManager/CLLocationManager.html#//apple_ref/occ/cl/CLLocationManager

No, there is a single API for this case. What hardware the device uses is abstracted away for you. The desiredAccuracy property may however influence what hardware is used. If you request a kCLLocationAccuracyBestForNavigation accuracy it will most likely use the GPS hardware which is more expensive on battery. However if you request a kCLLocationAccuracyKilometer accuracy it will likely use cell tower information and triangulation strategies, but may consult the GPS hardware occasionally. You really should not need to worry about this when using the Core Location framework.

Related

Get the location updates using wifi or cellular tower signal

I am developing an application, where I want to get the location details using CLLocationManager class. But if I call the startlocationupdating method, then GPS is started.
I don't want to get the location details using GPS. I want to turn GPS off and get the location details using WiFi or cellular towers. How I can do this?
From the CLLocationManager doc page (https://developer.apple.com/library/mac/#documentation/CoreLocation/Reference/CLLocationManager_Class/CLLocationManager/CLLocationManager.html)
For the services you do use, you should configure any properties associated with that service accurately. The location manager object 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. Turning off GPS hardware can lead to significant power savings.
Basically the wifi location kicks in disabling the GPS decreasing your accuracy level
Set desiredAcuracy to kCLLocationAccuracyKilometer;
You can proove that you dont have GPS by:
you never get course (degrees) (may also called heading, correct me)
you never get speed (m/s)
from your CLLLocation object, especially when moving
Further if you
dont get altitude,
its not GPS, too (also works when vehicle is stand still
the other possibility is to avoid GPS is to enable location service with "significantLocantionChange" mode. But for this i have no personal experience.

Does kCLLocationAccuracyThreeKilometers use GPS or Cell Tower?

please tell me that if I use kCLLocationAccuracyThreeKilometers instead of kCLLocationAccuracyBest.
Then will my iPhone use GPS or Cell tower?.
It will use a mixture of the GPS Reciever built in, Cellular tower data and WiFi data to gather the best location estimate. There is no guarantee that it will use WiFi only nor is there a flag you can set so it only uses WiFi. If Cellular data is not available (for example in a remote location), it will fallback to WiFi and GPS Receiver.
Using kCLLocationAccuracyThreeKilometers may have it rely on WiFi more often but there is no 100% certainty. It does however use less power so if it's sufficient to your needs then you'd be better off using that flag.

Get location of iPhone via GPS/IP

Im working on a application for which I need to decide in which country the user is. Which is the most accurate way to do this?
Should I use GPS or IP-adress?
What would be the pros/cons with each method?
I would use Apple's location services, which use several technologies (cell towers, WiFi hotspots, GPS, etc.) to determine their location. You can then find the country quite easily with a lookup of the GPS coordinates. I think this would be more accurate than by-IP lookups.
Its probably easier if you go via ip address and use a geo ip lookup service.
For GPS the GPS unit needs to be turned on. I guess lots of people disable it for energy saving. If you just turn on GPS for your check the user needs to get a gps fix first which can be time consuming as well.

how to find location using wifi in iphone

In my app, I am trying to figure out the location of my app user using WiFi (not GPS because my main area is inside the buildings), can any one please tell me how can I get user location using hotspot of WiFi.
Any basic guide or example is good .
Thanks in advance.
egards
Use Core Location. The Core Location framework hides the actual device capability from you (more or less) and (depending on the options you set) give you a best estimate for latitude and longitude. I've used the exact same app on an iPhone and iPod touch and have gotten pretty good results with the touch. It won't be as accurate, but it's good enough for most applications.
Check out the Core Location documentation and the "LocateMe" sample code from the developer site: https://developer.apple.com/library/ios/#samplecode/LocateMe/Introduction/Intro.html
Unless you mean to figure out the location of your user in a specific building with known Wi-Fi spots, you'll have to resort to using a IP address geolocation database. There are services, such as that provided by MaxMind, that have a database which you subscribe to for updates. The database maps IP addresses to locations.
This will only get you approximations, so your best bet is to use GPS primarily but IP address as a backup.

How does CoreLocation locate the device?

More specifically, does CL require the user to have a data connection? Or is it possible to just use the phones service connection?
Thanks!
It actually uses several mechanisms.
GPS
Cell Tower Triangulation
Wifi Hotspot cataloging
Randomly assuming you are in Cupertino
There are tradeoffs based on speed, precision, and available hardware. A first Gen iPad will only have the 3 option available while the iPhone simulator makes use of the last mechanism.
You can observe the difference in these systems in the map application where it initially guesses based on the cell tower, then refines the guess via GPS.
Only options #3 requires a data connection.
And for the humor impaired including #4 was not totally serious although it is functionally correct. (I think they simulate the GPS reporting that location rather than just hard coding it, but I haven't checked.)
You can set the phone into airplane mode and still get a location :)
It will be forced to use GPS to get it so it might take longer to get though.