For Production or Dev, you’re best to manage that setting on your own using an environment variable you can read. We use a local file in the file system that isn’t checked into source control that just says prod or dev or test and we check for the existence, that way when we publish our promotions to the build / test servers the code can know where its at.
To check if we’re on a mobile device or know, we kind of cheat. We use the push plugin (but you could use any native plugin). We look for the initialization of the push plugin, if it’s not initialized we assume we’re in the browser and not on a phone. It’s reliable in that even if the user on the phone answers ‘no’ to pushes, the plugin itself its initialized.
@bsampica thx you for your ideas, we hoped there is something more usable and integrated in the framework.
To check on which platform we are, we can check if platform.platforms() is core so we know we are on browser, and we think this should be easier to check if a cordova plugin is loaded.
To check if you are on dev or on prod we hoped there is a possibility to do this on bundling where you can set some environment variables. process.env.IONIC_ENV is a variable but only for bundling not for ionic framework. Are there nothing like this?
I think, we can only check if in platform.platforms() there is no no core and no mobileweb
core -> on desktop browser with livereload mobile AND mobileweb -> on android or ios device with livereload mobile WITHOUT mobileweb -> on android or ios WITHOUT livereload
if there is also cordova you know you run on emulator and not on device.
So I think this should be the solution for most of I asked, it remains the question which is the best way to check if you are on production or on dev mode?
On RC.4 there is no more mobileweb returning on platforms(), I think this is a bug and I opened a issue on github for it.
I found another solution to check if the app is running in abrowser, ass native app or as app with browser on device/emulatore so in livereload mode.
if (!document.URL.startsWith('file:///')) {
console.log('you are on livereload mode');
this.isLiveReload = true;
}
If the documen.URL startswith file:// I know I’m in a native app mode, if there is http or https: I know I’m running on desktop browser or on device/emulatore with livereload mode enabled.