CLLocationManager default coordinate values - ios

I'm learning to develop iOS apps and I try them on simulater only. Now, in my app I use CLLocationManager to get my current location coordinates. But when I run the app no matter where I am I get the same results for all the coordinate values(altitude,longitude,latitude). They do not change even if I move to another location. What I wonder is how does CLLocationManager get values? If it does not work on simulater then where do the values that never change come from? According to the coordinates I guess it's a default value that shows London if no coordinates are available.

Try Resetting the iOS Simulator, erasing all applications and settings.
And when you run CLLocationManager using application, it will probably ask for permission to use location, something like what you would see in you device.
I've been using iOS Simulator, and it gives location of my computer for the simulator all the time. I guess it's affected by your internet connection and IP address. Since many computers don't come with GPS, it's the only way to know the location of the computer.

The simulator always gives the location of Apple headquarters at Cupertino. It does not use computer's gps or location.

Simulator may use skyhook to check your location which is bounded to WiFi hotspot (if it was added with it's coordinates) and if you move in radius of WiFi coverage than your location won't be changed at all.

On the menu bar, go to Debug, then select Location, Custom Location and then you can input coordinates to simulate from. The Simulator will not always provide you the same feedback as a device would.

Related

How to simulate location for iOS app with plot projects integrated

We have integrated Plot Projects for monitoring geo fences. When using Apples region monitoring we can simulate location when running the project from Xcode, tried to do the same but not getting notification from Plot, how can I simulate location and get notification for testing purpose?
Thanks In advance,
To simulate a location on a device attached to the Xcode debugger, you can use the Debug->Simulate Location menu item in Xcode.
You can either use one the pre-set locations or add your own GPX file. A GPX file can contain a series of locations and Xcode will simulate movement between those locations in a loop.
Don't forget to select "Don't simulate location" when you are done or the location will still be simulated until you reboot the device.
If someone is looking for the answer, put your phone in airplane mode and simulate location and switch off airplane. You will get push notification. If you don't get, restart the phone and try simulate location with airplane off.

IOS side loaded App changing current location

Trying to develop my first application which will just be side loaded to my device. I am unsure if I can even do what I'm looking for; I'm trying to change the current location on my device via my application. I know this is done with the Xcode debugger but can it be done solely on the application with no connection to the computer? Basically I have a few buttons, each one I want to change the location to somewhere different. Do I just code the coordinates to set with the button and thats all? Will this show on my maps application and such? Thanks.
What you ask is not possible. The GPS hardware is what reports location to the phone. Xcode is able to do this because it is reporting location to the simulator, which has no GPS hardware on its own

GPS based VS Beacon based ranging? Which governs Lock screen left corner app icon

There are two approaches for showing an app/app suggestion (incase not installed) on the iphone lock screen / app switcher. One is GPS based, in which the IOS decides which app to show as a suggestion. Another is beacon based, in which a particular beacon is identified.
If location services are enabled for multiple apps and say all these apps are also using beacon based approach to show their icons on the lock screen left corner, which app icon will be shown by the IOS?
Since location services are enabled for these apps,and say there is another relevant app which is NOT using beacon based approach (using just the GPS based approach), can IOS give preference to beacon based apps over the GPS based this new app.?
For instance, Estimote’s NYC office is on the same block as an Equinox gym and our phones intelligently and automatically alert us to use that app. It’s super easy and intuitive to open the app while walking into the gym - and in the process, streamline the check-in flow with the gym’s front desk. However, because it solely uses GPS geofences, the accuracy is poor. We actually get the Equinox icon over 1 block away, and there is no control for the brands or stores (in this case Equinox) on how this appears.
Apple's suggestion of apps not installed on the phone based on proximity uses an undocumented technique. While I have verified it uses GPS as an input, I have never been able to confirm that beacons are used at all.
Regardless of whether beacons are used, because this is an undocumented feature, it is unlikely you will find a way to customize the behavior.
AFAIK, Apple has never shared the implementation details of how the lock screen icon AKA "suggested apps" feature works.
However, we did some experiments at Estimote and noticed that being inside a CLRegion (both the "GPS" CLCircularRegion, and CLBeaconRegion work) that an app monitors for via Core Location, consistently makes the app's icon show up on the lock screen. So it seems that both beacons and GPS location fall into the same mechanism that governs the location-based suggestions. (Note that in iOS 9, that's not just the lock screen icon, but also a bar at the bottom of the app switcher.)
Unfortunately, we weren't able to establish what happens if you're inside multiple qualifying CLRegions, belonging to different apps. We suspect it might have something to do with the order in which the apps register regions for monitoring, but were never able to get consistent results.
Furthermore, since this whole behavior is undocumented, Apple can change it at any time. Just something to be aware of.
Side note: handoff always trumps suggested apps.

Google maps ios api using user's location in fitbounds

I am trying to set a bounds between the users location and a selected marker. I can set everything up properly but when I try to use the users location (mapView_.myLocation.coordinate) it says the lat and long are both 0. I did create a button to center the camera on the users location and it gets the lat and long just fine. Does not make any sense to me. Also I don't have a device set up to test so I am using xcodes iOS simulator with a location put into the simulator (is that where my problem is?). Any ideas?
Are you trying to access myLocation.coordinate from loadView or similar, ie when the app first starts up?
Generally when enabling location services the app doesn't receive a location update immediately, it comes through after some delay. So it's possible that myLocation.coordinate won't be valid in loadView, but will have a value set some time later (which is why it works with your button).
You could perhaps listen for changes to myLocation, and then set your bounds when it changes to something.

How does MKMapView's showsUserLocation work?

As the mac desktop's simulator don't have location service, I can't try by myself and I choose to ask here.
the google map app can do continuous locationing for your device, as you move you can see the blue spot moving on the map.
But how can we develop app that does it?
Is it just
(1)enable the device location service in setting.
(2)add the codes: mapView.showsUserLocation = YES;
sufficient to do this? If yes, can we know how frequent does it update the location?
the similar query also raised on CLLocationManager class and its delegate.
how startUpdatingLocation method updates the device's location? and how frequent is it?
And, does startUpdatingLocation call the locationManager: didUpdateToLocation?
how does the former call the latter and what to implement in the latter?
Both CLLocationManager and MKMapView will use the AGPS of the iPhone.
AGPS means assisted GPS, which works by first giving you app the last know coordinates then using triangulation the hext coordinates, then it will start getting some real GPS coordinates.
It will keep tracking until you call the stopUpdatingLocation on CLLocationManager. There is no interval you will just be notified when ever a new set of coordinates is received.
Be aware that continues track of GPS will drain you battery.
I suggest you read the CLLocationManager documentation.

Resources