Geolocation conerns when releasing app

A large part of my app uses Geolocation and according to this post by Google:

Google has removed the Geolocation from unsecured locations. This is causing me to be unable to test my app in Chrome even though it’s on my local machine. I’m not sure why that is but I am just using Firefox so that’s not a big deal.

What I am concerned about is how this change will affect my app when I release it. Will I need to move my application to a secured HTTPS domain? Or is this not going to be an issue when I actually release my app?

Thanks!

You are using Geolocation locally in your Ionic app, right? Not on a website loaded from a browser, correct?

Yes correct. My concern is what will happen when I release it and it is no longer local. Will Geolocation still work?

How can it be “no longer local”?

But yes, if you plan to publish the app as a web app (PWA or otherwise) you may have to get a SSL certificate for your domain (which is free nowadays with Let’s Encrypt and all).

What do you mean by

[quote=“Sujan12, post:4, topic:81105, full:true”]

if you plan to publish the app as a web app [/quote]

My end goal is to have my application run on both Android and IOS with one code base. I thought all Ionic apps were all web apps which allows you to deploy it to Android or IOS? Can you publish it any other way?

When I publish my app as a webApp do I need to buy a domain? or does ionic supply me with one? I figured my app will “No longer be local” because I assumed when I published my app I can’t just have everyone access my app from my local machine I have to host it on some domain.

I will look into trying to get a SSL certificate.

Thanks.

Whoah, slow there. You misunderstood something here.

Yes, by default Ionic can build Android and iOS but also Windows or Browser applications - most users only use it for Android and iOS. Your “web app” (consisting of HTML and JS you write) will be wrapped in a native container that can run on the device. So when you upload your app to the app store it actually includes your “web app” in it! So for all the native applications, a standard Ionic app is always local as it is included in the app bundle and called locally.

Domain, SSL etc is only relevant when you want to publish your Ionic app to the web, too. But this is definitely advanced and not the standard use case (and also not really finished, yet).

Oh okay I see. So if it works locally it should work when I publish it. Would I be able to choose which browser the user runs on? Right now I am getting a “Only secured locations allowed” error when I call geolocation from Google Chrome using my local. However, it works on firefox.

When you run in chrome, you are not actually running your app from the local file system, Ionic starts up a web server. That’s why in your url you see http://localhost:8100 and not file://path/to/project/index.html. So in that case you will get that error in Chrome, because it’s running in a server as a regular website would.

However when you deploy to a device, it does not start up a web server, it just serves the files from the file system. In theory this will work fine, you could test it by simply doing ionic emulate android and checking that it works properly.

1 Like

I see, it actually runs fine on my device as long as I don’t do live reload but that’s not very useful for debugging if I can’t see any of the logs.

[quote=“MatTaNg5280, post:9, topic:81105, full:true”]
I see, it actually runs fine on my device as long as I don’t do live reload but that’s not very useful for debugging if I can’t see any of the logs.
[/quote] https://ionic.zone/debug/remote-debug-your-app#android

Oh cool that helps alot. Thanks for your help!