I am using iOS SDK 4.2 and followed this tutorial: http://mobileorchard.com/hello-there-a-corelocation-tutorial/, and got some GPS logs happening on the console using both iPhone and iPad.
Then I ran it on the simulator to test other features and the CoreLocation logs were hitting the locationManager:didFailWithError: method which is fair because the MacBookPro (OSX 10.6.6) has no GPS functionality... or so I thought.
This morning I tested it on the iPad again at work instead of at home and now testing on the iPhone simulator without any device connected the simulator is providing my location results of my office (No I don't work in Cupertino) and the horizontal accuracy is varying between 45-56m each time and only giving two samples at most (presumably because my notebook isn't moving).
Now I have fully closed XCode and the simulator and deleted the app from the simulator and performed a clean and rebuild and still getting my current coordinate. I can also replicate it without internet access incase the simulator was being tricky with some sort of GeoIP.
Where is the simulator getting my location from?
I thought perhaps maybe the simulator stored some GPS location data when I used the iPad this morning but with no device connected and clean starting everything it is providing varying results eg +/- 0.000001 of a degree variations.
From your MacBook's IP address or, if it's on WiFi, the stored location of your WiFi network. Since it's so accurate for you, it's the WiFi, since the IP address method generally narrows it only to a city, or at best, part of a city.
Skyhook provides geolocation information for most of the WiFi networks in the US and some other parts of the world, info that Apple subscribes to.
Edited to add
Apparently Apple ditched Skyhook last April and now uses its own database, but the system is the same. Much like Google got in hot water for in Germany, someone drives around with a computer looking for WiFi networks and recording their location.
Related
I am working on an iPhone and Mac OS X application, which allows you to lock and unlock your Mac via proximity. Means if you the signal strength is under a determined threshold or the connection gets lost it shall lock the mac.
I am working with Apples CoreBluetooth framework for BTLE, using the iPhone as a peripheral and the Mac as a central. So far so good. It also works very well but when I send the app to the background on the iPhone the advertising seems to change. The iPhone still advertises but without the service profile and characteristics, I use in the app.
Although this is not a problem when the iPhone is still in the range of the Mac, because it's still connected and the characteristics are not used in the central, it becomes a problem after moving the iPhone out of the range. As expected the Mac locks and starts discovering to reconnect the iPhone and unlock if succeeded.
But in this discovery, I use the specified service profile and the characteristics to only get devices running my app and to identify the one for unlocking.
I tried a workaround by discovering without a service profile and identifying the correct device via its UUID, which I saved when I started to use this iPhone for locking and unlocking. This workaround also works in a small scope, because when I turn off the Bluetooth on the iPhone and turn it on again, it gets another UUID. That's a constraint I could live with, but it also changes the UUID after a few hours and then the unlocking does not work.
Maybe someone already worked on an app like that and know how to fix such a problem? Or you know a static value which I can use to identify the device?
So it seems, like usual, Apple has some weird and unique things going on in their framework. When you advertise from an iOS device (such as your iPhone), there are two "storage areas" for the advertisements -- a normal one that any device that is scanning can see, and an "overflow" one that can only be seen by iOS devices that are specifically scanning for it. When your app advertises in the background, all services UUIDs that you advertise go into this overflow area unfortunately, so it looks like only other iOS devices can see it -- and not your Mac. From the CBPeripheralManager docs:
Any service universally unique identifiers (UUIDs) contained in the
value of the CBAdvertisementDataServiceUUIDsKey key that do not fit in
the allotted space are added to a special “overflow” area; they can be
discovered only by an iOS device that is explicitly scanning for them.
While your app is in the background, the local name is not advertised
and all service UUIDs are placed in the overflow area.
I was in Scotland with a Canadian phone recently, and to avoid roaming charges I had my cellular data turned off throughout the trip. However, the pictures I took still had accurate geotags, meaning my location was still available to my camera apps (even though I couldn't actually see these locations on a map until I got home).
My question is: how would I go about retrieving location data in a situation like that, where I can't actually display a map because there is no internet connection? And, just to improve my understanding, how is the location actually being retrieved? If "cellular data" is off, is GPS still available, or can the location only be calculated using nearby wi-fi hotspots at that point? And finally, if both cellular data AND wi-fi is turned off on a device, can location still be retrieved (i.e. is GPS still active)?
Any info on the subject is welcome - all I am trying to do is handle all possible situations created by the presence or lack of location services and an internet connection in an app where I (if possible) display and store the user's location.
Thanks!
iOS devices that have actual GPS hardware in them can give accurate location data even if there is no WiFi or cellular.
Of course, most map apps require an Internet connection to display a map. But if you have a map app with local map data, then you would be able to see the map with your position even without any Internet connection.
On devices with an actual GPS, location services works just fine with no Internet. It may take a little longer to zero in on your position but it still works normally. Of course on iOS devices with no real GPS, you do need a cellular or WiFi signal to get any position data.
I just got an old iPhone 3G for testing. It doesn't have a plan attached to it, but I just put in the sim card and it said it will take a while to activate.
When everyone has test devices, do you just leave the sim card out? What about when testing location based services that need to find cell towers? What do we do in situations like this? I don't want to pay for service.
You won't get anything out of the cell towers without a valid SIM card. I use my wife's old iPhone 3G for testing, and it still has the old AT&T sim card, but of course there is no service because that sim card is not on our account anymore. I always leave it in Airplane mode.
The main thing I'm verifying with the physical device is performance, UI responsiveness, and memory issues that present no problems in the simulator, but choke on this old device. The iPhone 3G is great to have on hand as a minimum baseline for that stuff.
The location-based stuff you should be able to mock up without needing any "real" data. Do a google search for "iphone" "mock location" and see what that turns up.
This looks promising:
http://rssv2.blogspot.com/2010/03/mocking-core-location.html
You don't want to have to develop with real, live data until you are in the beta stage anyways. Using real, live data during development is a huge hassle, not easily repeatable, and very time consuming. And this makes it impossible to write effective integration tests.
The iPhone has a GPS receiver, you don't need cell towers they just help speed up the process of acquiring the GPS satellites and finding your location. WiFi service will do the same thing but is not required. With no cell data and no wifi it can take several minutes to acquire GPS satellites, download ephemeris from the satellites and get a good location, but it works.
I use a 3G running 3.1.3 with no sim card for 3.1.3 testing and it works fine even for using location services, but I have wifi here.
I also use a CoreLocation simulator which allows me to simulate and repeat motion scenarios without going anywhere, it can simulate acquisition time, varying horizontal accuracy and motion. The simulator is available on github.
I'm trying to develop an iPhone application which uses the geolocation libraries. Is this feasible for the iphone simulator to simulate the GPS functionality without the use of my PC's Wi-Fi infrastructure? Does anyone know if the iphone simulator can spot your location using your IP-address only (so only the Ethernet cable connection is required)?
Thanks in advance.
You should test that functionality on an actual device. I believe the simulator will always show Cupertino, CA as the location.
No it won't work using ethernet. Core location appears to only work with WIFI even though at the end is the same router.
CoreLocation doesn't work in the simulator, but there are options
http://github.com/futuretap/FTLocationSimulator
Simulator doesn't have this functionality, but iSimulate has (it's not mine :-( ). It connects the device and simulator per WiFi and sends location events to the application within simulator: real GPS events and a few predefined locations around the world. Pretty cool!
Is it possible to simulate movement (ie the accelerometers), microphone and camera in the XCode simulator?
If so, how do you do it?
If not, are there any XCode addins or third party apps that do it? (apart from downloading to an actual iPhone of course).
Thanks in advance!
The easiest way I found to do it is using the Wavefront Accelerometer Data App that can be found in the App Store. All you need to do is add a single file to your application then you can use the accelerometer in your iPhone or iPod touch to send data to your app in the simulator. You'll need a WiFi connection, and a device to use.
You could probably find a solution that runs on the desktop, but you won't be getting accurate real life readings.
I would recommend getting an actual device or your app can behave different than you expect it to. If this is a serious endeavor, you should be able to justify the cost of a device. An iPod Touch is much cheaper but you don't get the phone or camera capability. You can get a headset that has a microphone though.
Those are the limitations, I don't think it wise to develop an app without testing it on a device. I've run into apps that crash all the time and figure it's because they are getting away with stuff in the simulator that you can't do in the memory and cpu constraints of the device.
Microphone works in the simulator. It uses a standard mic input from your mac.
Check this link....
http://media.wiley.com/product_data/excerpt/72/04705009/0470500972-1.pdf
and go to 10 th page..
However, the iPhone Simulator, being a software simulator for the real device, does have its
limitations. Features not available on the iPhone Simulator include:
Obtaining location data — it returns only a fi xed coordinate, such as Latitude 37.3317
North and Longitude 122.0307 West
Making phone calls
Accessing the Accelerometer
Sending and receiving SMS messages
Installing applications from the App Store
Camera
Microphone
Several features of OpenGL ES
In the android simulator the hardware can't be simulated .. but for example for the camera i see an approach to get real information ... Use your webcam .. to do that you can get frames with an app and send this data with a socket to the simulator... maybe it's possible to do that with iPhone simulator.
I see this solution here