In Ionic 3, you could tell if it was installed on a device by using
if (!(<any>window).cordova)
isDebug = true;
This doesn't appear to work in Ionic 4. This always comes back as false.
What is the preferred method to detect if it's a debug vs a production build?
environments/environment.prod.ts
export const environment = {
production: true
};
environments/environment.ts
export const environment = {
production: false
};
Your page
import { Platform } from '@ionic/angular';
import { environment } from './environments/environment';
@Component({...})
export MyPage {
constructor(public platform: Platform) {
if(platform.is('cordova')) {
console.log('cordova');
}
console.log(Prod? ', environment.production);
}
}
Commands
ionic build --prod // Prod? true
ionic build // Prod? false
ionic s // Prod? false
ionic s --prod // Prod? true