core-location

Region Monitoring method getting called multiple times in Geo-Fencing

若如初见. 提交于 2019-12-13 18:53:28
问题 I have created multiple geo-fence to monitor region entry/exit events. I have created a location manager in AppDelegate.h file. @interface AppDelegate : UIResponder <UIApplicationDelegate, CLLocationManagerDelegate> @property (strong, nonatomic) UIWindow *window; @property(nonatomic,retain)CLLocationManager *locationManager; @property(nonatomic,retain)CLLocation *currentLocation; +(AppDelegate *)sharedDelegate; AppDelegate.m file - (BOOL)application:(UIApplication *)application

How do silent notification behave once phone got Power off & On

主宰稳场 提交于 2019-12-13 16:30:30
问题 I have a application which tries to grab location of user using silent notification at certain situations. I am able to send silent notification to the phones and able to run the background fetch and get the location back to web-service. Comparing the user payload of silent notification I am doing some operation(Initiating the location manager & grabbing location from delegate method) while app is in background/suspended mode. This works in all other cases expect one case which is iPhone

Tips for conserving battery if CoreLocation must constantly retrieve the user's location?

我是研究僧i 提交于 2019-12-13 16:23:08
问题 The application will select a random latitude and longitude to create a point which the user must find. The user's distance from the point will be displayed using a "hot-cold meter", which will change color depending on the distance. This meter must constantly update, which would require that I constantly retrieve the user's location. I would also need to use kCLLocationAccuracyBest . However, this sounds like it would use up a lot of battery. Can I do anything to save battery? 回答1: From the

Latitude & Longitude Not Retrieved

空扰寡人 提交于 2019-12-13 15:55:15
问题 UPDATED for iOS9: I am new to iOS, experimenting with CoreLocation to return latitude and longitude values. The following code never executes the log output -(void)viewWillAppear:(BOOL)animated{ manager = [[CLLocationManager alloc]init]; manager.delegate = self; manager.desiredAccuracy = kCLLocationAccuracyBest; [manager startUpdatingLocation]; } Here is my didUpdateToLocation function with is never reached - (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray

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

荒凉一梦 提交于 2019-12-13 12:32:42
问题 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

SwiftUI with Core Location as ObservableObject crashes

大憨熊 提交于 2019-12-13 12:21:59
问题 I am trying to use Core Location to get the CLRegionState to update elements in a SwiftUI app. I am using XCode 11 beta 6 and have iOS 13 beta 7 on my device. There are two problems that I can see: The app crashes and the error Thread 1: EXC_BAD_ACCESS appears on line 147 (...ScrollView {... ) The CLRegionState is never called or does not update. I am basing this off of Paul Hudson's tutorial on SwiftUI Beacon Detector (which I have not been able to make work either), and modifying it to use

iOS re-check location on load from background

妖精的绣舞 提交于 2019-12-13 11:50:57
问题 I'm building an app which displays result data based on your current location. At the moment, I'm using the viewDidLoad method of a UIViewController to start the CLLocationManager and getting the current location. Once I have the location that matches the accuracy I desire, I do a request to my web service to get the results and dump it into a UITableView . My problem is that when you close the app (although it's still running in the background). If you were to drive to another town, re-open

iOS13 Provisional Location Permission

谁都会走 提交于 2019-12-13 11:22:10
问题 Since apple has deferred the "Always Allow" permission and only OS can and will ask for that permission based on its own convenience, it is hard to understand what all the scenarios are. If you see the WWDC video: https://developer.apple.com/videos/play/wwdc2019/705/ The guy clearly says at 04:14, "you ask for requestAlwaysAuthorization, apple provides you with the max option of "While In Use", but at the same time the delegate callback says, the app has "Always Allow permission"". This works

How do I get the users location latitude and longitude?

对着背影说爱祢 提交于 2019-12-13 09:39:02
问题 I need to access the users location in this method contained in the mainViewController -(void)loadAnnotations{ [mapView removeAnnotations:mapView.annotations]; CLLocationCoordinate2D workingCoordinate; workingCoordinate.latitude= //here i need the users latitude workingCoordinate.longitude= //here i need the users longitude NSLog(@" this is %@", workingCoordinate.latitude); iProspectLiteAnnotation *tempMine = [[iProspectLiteAnnotation alloc] initWithCoordinate:workingCoordinate]; [tempMine

How to get borough from UK postcode using CoreLocation in swift?

时光怂恿深爱的人放手 提交于 2019-12-13 08:49:04
问题 Does anyone know if I can get the borough from a UK post code using CoreLocation framework? In the function listed below, the borough is not returned. It should return Tower Hamlets. func getLocationFrom(postalCode : String){ let geocoder = CLGeocoder() geocoder.geocodeAddressString(postalCode) { (placemarks, error) -> Void in let placemark = placemarks?[0] print("placemark.addressDictionary are \(placemark.addressDictionary)") //does not print Canary Wharf } } print(getLocationFrom