Accessing an environment variable to recognise if deployed on Mobile App or Web App?

Hi I am using Ionic 5 with Angular. I have a mobile app that I am currently developing a Web App for that uses the same codebase as the mobile app.

I’m looking for a way to configure some environment variables to recognise if the app is deployed on Mobile App or Web App. Thanks :slight_smile:

You don’t need that. You can use Ionic’s Platform

2 Likes

I would additionally urge caution here, because once you introduce any sort of knowledge like this, it becomes very easy for you to wake up one day and discover that you don’t actually have one codebase - you have two or three or eight codebases that are snarled together in a forest of conditionals.

IMHO, the maintainability of hybrid apps is highly dependent on what percentage of the code has no clue how it’s deployed.

1 Like