cordova-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Garth Gutenberg (JIRA)" <>
Subject [jira] [Commented] (CB-5753) iOS: CDVLocation locationManager didFailWithError
Date Fri, 17 Oct 2014 17:44:34 GMT


Garth Gutenberg commented on CB-5753:

I've found that an error always occurs within 8-12 mins of backgrounding an app that's receiving
location updates.  This is a huge problem for fitness tracker apps, as the app simply stops
listening to location updates after that error occurs.

In order to work around this, I've modified CDVLocation.m, specifically the didFailWithError
override.  I've removed lines 346 and 347:

//    [self.locationManager stopUpdatingLocation];
//    __locationStarted = NO;

I personally have no idea why this would have been written in a way such that location updating
would simply stop because an error was thrown.  By removing these two lines the app continues
functioning properly even if an error occurs.  However, as noted in the second part of this
issue, the fact that an error occurs does not bubble up to the JS layer, so it's impossible
to handle it.  But an invisible error is better than a fatal error, at least in my scenario.

> iOS: CDVLocation locationManager didFailWithError
> -------------------------------------------------
>                 Key: CB-5753
>                 URL:
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Plugin Geolocation
>    Affects Versions: 2.9.0, 2.9.1
>         Environment: iOS
>            Reporter: Martin Robin
>              Labels: patch
> The delegate handler for didFailWithError appears to have a couple of issues...
> According to the [documentation|],
{quote}If the location service is unable to retrieve a location right away, it reports a kCLErrorLocationUnknown
error and keeps trying. In such a situation, you can simply ignore the error and wait for
a new event.{quote}
> The handler within CDVLocation does not however take this into account and as a result
if this error is raised it causes the location manager to be shut down without any warning.
> Within the same handler, there appears to be code to send a notification back to the
JavaScript by way of the onError function. This notification is never received in the JavaScript
so the error cannot be handled (by calling clearWatch and then restarting with a call to watchPosition
for example).
> The first problem is (I believe) fairly easily resolved; simply ignoring the error (though
possibly notifying the JavaScript) would suffice.
> I have no idea how to resolve the second problem. I have tried tracing the code and it
appears to call commandDelegate::sendPluginResult (via returnLocationError) but the onError
function in the (my) JavaScript does not receive the error. I do not understand how the plug-in
model works enough to be able to follow up any further for myself.

This message was sent by Atlassian JIRA

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message