Skip to content
Permalink
Browse files
CB-6911 - Geolocation fails in iOS 8
  • Loading branch information
shazron committed Sep 3, 2014
1 parent d794292 commit 1c18ea07948775b5b1b4e2d964836b757fc21fd9
Showing 2 changed files with 10 additions and 0 deletions.
@@ -105,6 +105,11 @@ xmlns:android="http://schemas.android.com/apk/res/android"
<header-file src="src/ios/CDVLocation.h" />
<source-file src="src/ios/CDVLocation.m" />
<framework src="CoreLocation.framework" />

<config-file target="*-Info.plist" parent="NSLocationWhenInUseUsageDescription">
<string></string>
</config-file>

</platform>

<!-- blackberry10 -->
@@ -122,6 +122,11 @@ - (void)startLocation:(BOOL)enableHighAccuracy
// first stop, and then start the updating to ensure we get at least one
// update, even if our location did not change.
[self.locationManager stopUpdatingLocation];

if (IsAtLeastiOSVersion(@"8.0")) {
[self.locationManager performSelector:NSSelectorFromString(@"requestWhenInUseAuthorization") withObject:nil afterDelay:0];
}

[self.locationManager startUpdatingLocation];
__locationStarted = YES;
if (enableHighAccuracy) {

4 comments on commit 1c18ea0

@Chizzl
Copy link

@Chizzl Chizzl commented on 1c18ea0 Oct 9, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Background location tracking is still failing with iOS8. (Due the missing "Always" privacy option? (Settings > Privacy > Location)) Are there any updates planned or workarounds available?

@shazron
Copy link
Contributor Author

@shazron shazron commented on 1c18ea0 Oct 9, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,
You're referencing old code. the latest code should support background location tracking. However, by default we don't include the NSLocationAlwaysUsageDescription (only NSLocationWhenInUseUsageDescription which is foreground only), so currently you'll have to add that yourself manually. I'm thinking of a small plugin to add this key automatically - stay tuned.

@shazron
Copy link
Contributor Author

@shazron shazron commented on 1c18ea0 Oct 9, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sent a pull request: #28

In the meantime, you can try installing it from my branch:

cordova plugin add https://github.com/shazron/cordova-plugin-geolocation.git#CB-7754:src/ios/background-location

Please test it out.

@sandstrom
Copy link

@sandstrom sandstrom commented on 1c18ea0 Mar 12, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NSLocationWhenInUseUsageDescription gets overwritten with a blank string if it exist in the plist. This makes it harder to provide a custom description (which is the purpose of the string, btw).

Don't know if the plugin facility allows, but if it could handle this 'softly', e.g. only add the key to the plist unless it already exists, that would solve it.

Please sign in to comment.