Separate mobile and desktop code?


I’m currently using Ionic 4 to make the mobile apps. with usages of cordova native plugins i know it won’t work with the desktop platform. should i continue to use ionic for desktop/browser and just add‘cordova’) to not execute any cordova native plugins? or is there a better way to handle this? or i might need to write another angular project targeting browser?


Hi @pefe,

Checking'cordova') to avoid calling native plugins on the browser is the way to go. My advice is to use the same project for all platforms, otherwise you won’t be benefiting from having a single codebase.

A little trick: since you also have to wait for platform.ready() before you use a plugin, this promise also returns cordova or dom, so you don’t have to use'cordova') later:

async myFunction() {
  const readySource = await this.platform.ready();

  if (readySource === 'cordova') {