Search code examples
angularadmobadsensecapacitor

Is it possible in an angular web app to run slightly different code on mobile using capacitor?


I would like to add google ads to my app, but you need to use admob for web and adsense for mobile. First I wanted to use angular native, but I couldn't get it running and I found capacitor, but I don't quite understand their doc about Environment Specific Configurations. Any advice how could I do it?


Solution

  • You can use getPlatform() or isNativePlatform() to check the environment:

    if (Capacitor.isNativePlatform()) {
      // Native app running on Android or iOS
    }