Apache Cordova
  1. Apache Cordova
  2. CB-544

iOS Geolocation fails if Cordova.plist EnableLocation = YES

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 1.6.0, 1.6.1, Master
    • Fix Version/s: 1.7.0
    • Component/s: iOS
    • Labels:
      None

      Description

      Since 1.6.0, Cordova will return POSITION.UNAVAILABLE in all geolocation JS calls unless, counterintuitively, 'EnableLocation' is set to 'NO' in Cordova.plist

        Activity

        Show
        Shazron Abdullah added a comment - Fix commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/commit/159cdfe4
        Hide
        Shazron Abdullah added a comment -

        When EnableLocation is set to YES, it calls the Location plugin and calls "startLocation" on the plugin, which with the new updated code, does not initialize self.locationData first (it is only initialized in [1]) and it will be null, thus getting Position.UNAVAILABLE always because of that variable being null [2].

        The fix is, on this line [3] you need to call getLocation instead, to initialize everything.

        [1] https://github.com/apache/incubator-cordova-ios/blob/master/CordovaLib/Classes/CDVLocation.m#L287
        [2] https://github.com/apache/incubator-cordova-ios/blob/master/CordovaLib/Classes/CDVLocation.m#L320
        [3] https://github.com/apache/incubator-cordova-ios/blob/master/CordovaLib/Classes/CDVViewController.m#L161

        Show
        Shazron Abdullah added a comment - When EnableLocation is set to YES, it calls the Location plugin and calls "startLocation" on the plugin, which with the new updated code, does not initialize self.locationData first (it is only initialized in [1] ) and it will be null, thus getting Position.UNAVAILABLE always because of that variable being null [2] . The fix is, on this line [3] you need to call getLocation instead, to initialize everything. [1] https://github.com/apache/incubator-cordova-ios/blob/master/CordovaLib/Classes/CDVLocation.m#L287 [2] https://github.com/apache/incubator-cordova-ios/blob/master/CordovaLib/Classes/CDVLocation.m#L320 [3] https://github.com/apache/incubator-cordova-ios/blob/master/CordovaLib/Classes/CDVViewController.m#L161

          People

          • Assignee:
            Shazron Abdullah
            Reporter:
            Marvin Plummeridge
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development