core-location

Background location tracking not working on physical device swift

橙三吉。 提交于 2019-12-06 12:20:44
问题 I followed this tutorial (https://www.raywenderlich.com/92428/background-modes-ios-swift-tutorial) to create an app that maps the user's location in the background. It asks to follow the user's location even when the app is closed, the user presses yes, and it tracks location in the background, updating every second or so. It works perfectly in the simulator, but sideloaded onto a physical iPhone 6, it stops checking the user's location in the background. 回答1: I solved this. If your

how is it that CLLocationManager gets a location when Airplane Mode is ON

梦想的初衷 提交于 2019-12-06 11:16:08
My app uses CLLocationManager to get location updates from the device. I had assumed that when the device was in Airplane Mode, I would not get location updates. But I do. The reason I assumed this is because Apple says that Airplane mode turns off Wifi, Cellular, Bluetooth, and GPS. See: http://support.apple.com/kb/ht1355 So, how is it that I'm getting a location update with a coordinate that seems reasonable? I've developed an app that heavily uses the user location, so I had to check this and other situations. I've learned that when all the services are off (Bluetooth, Wi-Fi, Cell Data)

What's the maximum number of regions that can be monitored on iPhone?

核能气质少年 提交于 2019-12-06 10:55:31
问题 Any one know what's the maximum number of shared regions is? Do you get regionMonitoringDidFail call if you exceed it? http://developer.apple.com/iphone/library/documentation/CoreLocation/Reference/CLLocationManager_Class/CLLocationManager/CLLocationManager.html#//apple_ref/occ/instp/CLLocationManager/monitoredRegions 回答1: I can't get it to accept more than 10 regions. No error message just monitoredRegions does not get any members after 10. edit: if I add a lot (around 60) of regions

How to calculate distance using accelerometer using iphone sdk?

左心房为你撑大大i 提交于 2019-12-06 09:36:57
What is the best way to calculate the distance between two points/Or we can say while we walk calculate distance traveled using accelerometer? My main question is that i'm working on an application in which i need to count distance using two locations but sometimes the core locations fails to update location so at that time how do i calculate the distance traveled? Dave DeLong You can't even get an accurate measurement of velocity from the accelerometer , so you're definitely not going to be able to get an accurate measure of distance traveled. 来源: https://stackoverflow.com/questions/2115288

MKMapView: Zoom to default “country level”

天大地大妈咪最大 提交于 2019-12-06 08:55:39
问题 when putting a MKMapView into a UIViewController and setting it to Satellite view, the map is zoomed and adjusted to show the whole country the user is current located in: For example the United States as shown below. When the user is now zooming the map or I'm zooming the map programmatically, it doesn't seem to be able to restore this default zoom level. Of course I could find out the coordinates of this default zoom in order to zoom back to that setting, but practically I would need to do

How to map MCC + MNC to users phone country code in iOS objective-C without using Location info?

谁说胖子不能爱 提交于 2019-12-06 08:48:01
I want the actual country code of the users phone number without prompting the user for Location Permission. How do I get it? Here is the code I use to get the MCC and MNC CTTelephonyNetworkInfo *networkInfo = [[CTTelephonyNetworkInfo alloc] init]; CTCarrier *carrier = [networkInfo subscriberCellularProvider]; NSString *mcc = [carrier mobileCountryCode]; NSString *mnc = [carrier mobileNetworkCode]; I get MCC - 310 and MNC - 410 which corresponds to AT&T USA. But what I want is '+1' the country code dialing for the user. Alternatively, Is it possible to do it with NSLocale? Try this NSLocale

iPhone: maximumElapsedTimeForCachedLocation used to remove cache value of core location

我是研究僧i 提交于 2019-12-06 08:44:39
In certain cases, cached values are immediately returned when starting a location service. Any location with a time interval older than this value will be considered invalid. @property (nonatomic, assign) NSTimeInterval maximumElapsedTimeForCachedLocation Declared In UABaseLocationProvider.h Do any of you know how to use this maximumElapsedTimeForCachedLocation in Core Location for removing the cache value of the old location? 来源: https://stackoverflow.com/questions/12909910/iphone-maximumelapsedtimeforcachedlocation-used-to-remove-cache-value-of-core-l

How does the distanceFromLocation method work?

做~自己de王妃 提交于 2019-12-06 07:45:45
I frequently use the distanceFromLocation method for CLLocation objects to get their distance from other locations. Enumerating through an array of CLLocations, I then compare each to my reference location using this method. I'm curious to know the processing/memory implications for using distanceFromLocation , especially for a large number of CLLocation objects in succession. How does this method work - does it connect to the server to get the data, or does it calculate the distance based on some mathematical formula, such as the Haversine Formula ? Is there a more efficient method to compare

startMonitoringForRegion not always adding regions to monitoredRegions

[亡魂溺海] 提交于 2019-12-06 06:02:35
I can not get startMonitoringForRegion to consistently add regions. int i =0; for(Deals *d in deals){ NSLog(@"deal addRegionsInDealsArray %@",d.deal_id); if (d.latitude != NULL && d.longitude!=NULL && ![d.latitude isEqualToNumber:[NSNumber numberWithInt:0 ]] && ![d.longitude isEqualToNumber:[NSNumber numberWithInt:0 ]]) { CLLocationCoordinate2D dl = CLLocationCoordinate2DMake( [d.latitude doubleValue], [d.longitude doubleValue]); //NSLog(@"Lat addRegionsInDealsArray %@",d.latitude); CLRegion * clr = [[CLRegion alloc] initCircularRegionWithCenter:dl radius:radius identifier:d.deal_id];

WatchKit CoreLocation issue

寵の児 提交于 2019-12-06 05:16:38
问题 I am trying to read current location coordinates in WatchKitExtension ExtensionDelegate. This does though not return any value. The very same code used in WatchKitExtension InterfaceController does return the location. (tried this out of desperation as I could not find an error in the code) I would need to perform this code in ExtensionDelegate as I would like to pass the retrieved location on to a ClockKit Complication. Here the code in ExtensionDelegate: (after self.locationManager