iOS8: Blue bar “is Using Your Location” appears shortly after exiting app

We frequently report things to Apple, and sometimes they actually act upon it. Exactly to prevent the blue bar from appearing shortly as described in the question, Apple has introduced a new property on CLLocationManager in iOS-9. Set it at the moment you know you will need the location in the background: theLocationManager.allowsBackgroundLocationUpdates = YES; … Read more

Find city name and country from latitude and longitude in Swift

You can use CLGeocoder reverseGeocodeLocation method to fetch a CLPlacemark and get its country and locality properties info. Note that it is an asynchronous method so you will need to add a completion handler to your method when fetching that info: import UIKit import MapKit import PlaygroundSupport PlaygroundPage.current.needsIndefiniteExecution = true extension CLLocation { func fetchCityAndCountry(completion: … Read more

iOS – MKMapView place annotation by using address instead of lat / long

Based on psoft‘s excellent information, I was able to achieve what I was looking for with this code. NSString *location = @”some address, state, and zip”; CLGeocoder *geocoder = [[CLGeocoder alloc] init]; [geocoder geocodeAddressString:location completionHandler:^(NSArray* placemarks, NSError* error){ if (placemarks && placemarks.count > 0) { CLPlacemark *topResult = [placemarks objectAtIndex:0]; MKPlacemark *placemark = [[MKPlacemark alloc] … Read more

What do horizontalAccuracy and verticalAccuracy of a CLLocation refer to?

The -1 for verticalAccuracy indicates that the altitude in the CLLocation is not valid. You only get altitude with a 3D GPS position. The 1414 for horizontalAccuracy indicates that the horizontal (lat/lon) position could be up to 1414m off (this is just an estimated error). This is probably a location determined by cell tower triangulation … Read more

iOS – CoreLocation and geofencing while app is closed

According to the Apple Documentation, in the Using Regions to Monitor Boundary Crossings section: In iOS, the regions you register with the location manager persist between launches of your application. If a region crossing occurs while your iOS app is not running, the system automatically wakes it up (or relaunches it) in the background so … Read more

How to get current longitude and latitude using CLLocationManager-Swift

IMHO, you are over complicating your code when the solution you are looking is pretty simple. I have done it by using the following code: First create an instance of CLLocationManager and Request Authorization var locManager = CLLocationManager() locManager.requestWhenInUseAuthorization() then check if the user allowed authorization. var currentLocation: CLLocation! if CLLocationManager.authorizationStatus() == .authorizedWhenInUse || CLLocationManager.authorizationStatus() … Read more

NSUserDefaults losing its keys & values when phone is rebooted but not unlocked

I was having a very similar issue. Background the application. Use other memory heavy applications till my application gets jettisoned from memory. (You can observe this event if you have your device plugged and xcode running the build. Xcode will tell you “application was terminated due to memory pressure). From here if your application is … Read more

Request permissions again after user denies location services?

The OS will only ever prompt the user once. If they deny permission, that’s it. What you can do is direct the user to the Settings for your app by passing UIApplicationOpenSettingsURLString to UIApplication‘s openURL: method. From there, they can re-enable location services if they wish. That said, you probably shouldn’t be too aggressive about … Read more

NSInternalInconsistencyException: ‘Invalid parameter not satisfying: !stayUp || CLClientIsBackgroundable(internal->fClient)’

I’ve managed to solve this by doing these two things: added UIBackgroundModes ‘location’ to Info.plist added NSLocationAlwaysUsageDescription to Info.plist As of iOS 11, keys are named: NSLocationAlwaysAndWhenInUseUsageDescription and NSLocationWhenInUseUsageDescription

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)