Issue getting Geolocation in iOS


#1

Hi,

I am using Meteor 1.3.4.4 on macOS and using Xcode 8.

After much effort to get my mobile app working in iOS 10 I am stumped on getting the geolocation working. The error I am getting is;

[blocked] Access to geolocation was blocked over insecure connection to http://localhost:12384.

I did build my mobile app using a secure connection using

meteor run ios-device --production --mobile-server https://server123123.ngrok.io/ 

Is Cordova/Meteor running its own web-server on the device and trying to access Safari geolocation API over an in-secured connection?

Any help is appreciated. Thank you.


#2

For iOS 10 you need to have this key in your Info.plist:

My project already had that, so if yours doesn’t, maybe you have an old version of Cordova. Also make sure that you have the following in your mobile-config.js file:

App.accessRule('*');

#4

Thanks for the reply. I just checked my Info.plist and I have all those strings however still getting the issue. I also added the accessRule with no luck :frowning:


#5

I also had to add a port 443 and an equals sign before mine worked, but I think turning round three times and throwing salt over my shoulder also helped!

–mobile-server=https://server123123.ngrok.io:443


#6

Ok, so I fixed this issue after a few hours of effort.

I had to wrap my code to check if it was a Cordova app where before I didn’t. No idea why this was causing the issue but it fixed the issue.

if(Meteor.isCordova){
    Meteor.startup(function () {

      Location.startWatching(function(pos) {
          if (gpsLogging) console.log("Got a position!", pos);
        //  Location.enableAccuracyFilter(12);

          latLng = Location.getReactivePosition();

          Tracker.autorun(function() {

            Meteor.subscribe('userfieldsByGPS',latLng.longitude,latLng.latitude);

          });



      }, function(err) {
          if (gpsLogging) console.log("Oops! There was an error", err);
      });

    });
}

#7

I had the same issues and tried the above solution and it worked. Just for the record, I had this working before without a Meteor.startup(function () … but now that was necessary…

Anyway. Thanks for the help!