How can I compare CLLocationCoordinate2D

Either the generic approach for comparing two instances of any given struct type: memcmp(&cllc2d1, &second_cllc2d, sizeof(CLLocationCoordinate2D)) or cllc2d1.latitude == cllc2d2.latitude && cllc2d1.longitude == cllc2d2.longitude should work, if you really want to be sure they’re exactly equal. However, given that latitude and longitude are defined as doubles, you might really want to do a “close enough” … Read more

How to solve Xcode 4.1 (LION) GPS error?

Xcode 4.2 solved this problem adding custom gps position! The file is an XML like this: <?xml version=”1.0″?> <gpx version=”1.1″ creator=”Xcode”> <wpt lat=”45,49939″ lon=”9,12114″> <name>Milano</name> </wpt> </gpx> you can add this file in your project or New->File->GPX. While you’re running your app, activate the console and select your custom position file: it’s all. enjoy.

Location permission alert on iPhone with PhoneGap

You need to do the geolocation after the device is ready. The following Jquery code, for example, will geolocate without that nasty alert: $(function(){ document.addEventListener(“deviceready”, onDeviceReady, false); }) function onDeviceReady() { navigator.geolocation.getCurrentPosition(onSuccess, onError); } function onSuccess(position) { // your callback here } function onError(error) { // your callback here }

allowsBackgroundLocationUpdates in CLLocationManager in iOS9

This new property is explained in the WWDC session “What’s New in Core Location”. The default value is NO if you link against iOS 9. If your app uses location in the background (without showing the blue status bar) you have to set allowsBackgroundLocationUpdates to YES in addition to setting the background mode capability in … Read more

In iOS, what is the difference between the Magnetic Field values from the Core Location and Core Motion frameworks?

To unravel this I’ve spent a bit too much time digging through the Apple docs. There are three ways of obtaining magnetometer data 1/ Core Motion framework CMMotionManagers’s CMMagnetometer class 2/ Core Motion framework CMDeviceMotion CMCalibratedMagneticField property 3 / Core Location framework CLLocationManager’s CLHeading 1/ supplies ‘raw’ data from the magnetometer. 2/ and 3/ return … Read more

didUpdateLocations instead of didUpdateToLocation

I asume you used the following delegate to get the last position? – (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation The delegate above is deprecated in iOS 6. Now the following should be used: – (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations In order to get the last position, simply get the last object of the array: [locations lastObject] … Read more

iOS: App is not asking user’s permission while installing the app. getting kCLAuthorizationStatusNotDetermined every time – Objective-c & Swift

iOS8 has got us major API changes with the LocationsServices Assuming [CLLocationManager locationServicesEnabled] return YES, With the First Launch of the iOS App [both iOS7 and iOS8] – locationMangers(CLLocationManager) authorizationStatus preset to authorizationStatus(CLAuthorizationStatus) = kCLAuthorizationStatusNotDetermined Prompting in iOS7+ Initiate the locationManger (CLLocationManager , Strong) and set the delegates(CLLocationManagerDelegate) Now to prompt the user to use … Read more

How can I prompt the user to turn on location services after user has denied their use

With iOS8, you can finally link user to Settings app via openURL. For example, you can create a UIAlertView with a single button that takes user to the Settings app: UIAlertView *alert = [[UIAlertView alloc] initWithTitle:ICLocalizedString(@”LocationServicesPermissionTitle”) message:ICLocalizedString(@”LocationPermissionGeoFenceMessage”) delegate:self cancelButtonTitle:@”Settings” otherButtonTitles:nil]; [alert show]; In your UIAlertView delegate: – (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { [alertView dismissWithClickedButtonIndex:buttonIndex animated:YES]; [[UIApplication … Read more

Xcode / iOS simulator: Trigger significant location change manually

So two answers: A) Hop on a train 🙂 B) Use the simulator. In iOS 5.x simulator, there is a debug menu that has a location submenu. Choose freeway drive. This will start the simulator on an imaginary journey down the scenic 280 in Northern California. It gives you everything but the view: your app … Read more

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