Ionic Native: Mocking Plugins for Browser usage

In theory Ionic Native offers this awesome possibility to mock the plugins for browser usage: https://ionicframework.com/docs/native/browser.html
But in practice I couldn’t find almost no examples of this.

Does it actually work?
Do you have any great examples?

How would I implement a Mock that required no code changes so it also works in Cordova on device?

This is a quick article I wrote a while ago when this functionality first came out, but it should still work (people may have come up with better methods by now, not sure): https://www.joshmorony.com/automating-mocks-in-ionic-native-3-x/

Basic concept is to get your application to automatically use the mocks when running on a desktop browser, and to not use the mocks when built with Cordova.

1 Like