Skip to content

Dev mode and production mode configuration

leob edited this page Feb 26, 2016 · 8 revisions

In production mode (if you run on a device with ionic build or ionic run) then by default Firebase will be used for login/authentication.

This is because in "production mode" the settings in the config-prod.json file are used, which set devMode = false.

This flag, in turn, causes the user service to point to the Firebase implementation (see https://github.com/leob/ionic-quickstarter/blob/master/src/js/app/user/services/user.service.js to understand how this works).

If you want to run in production mode but do NOT want to use Firebase but another implementation (for instance the 'mock' implementation), then you can do this in two ways:

The second way is in fact the recommended way because the devMode flag has other side effects apart from switching service implementations (for instance, devMode = true switches AngularJS to "debug" mode - this is good for development but you do not want this in a live production app, because it makes your app inefficient).

Note: from the previous discussion it will be clear that running on a device, or in a browser ('ionic serve') is in fact completely independent from whether you use 'mock' implementations or Firebase implementations of a service.

So, if you want you can run in 'development' mode (ionic serve) but use Firebase for your login/authentication (or for other backend services). In many cases, this is what you want - for initial prototyping the 'mock' implementation may be fine but for serious development you will want to switch to a 'real' backend.

The best (most flexible) way to do this is to edit the code of the service (e.g. https://github.com/leob/ionic-quickstarter/blob/master/src/js/app/user/services/user.service.js) so that it instantiates the implementation (mock or Firebase) that you want.

NOTE: if you modify the code of the user service (see https://github.com/leob/ionic-quickstarter/blob/master/src/js/app/user/services/user.service.js) then you will probably want to make the same modification to other services which have both a "Firebase implementation" and a "Mock implementation". See for instance the 'AppHooks' service (https://github.com/leob/ionic-quickstarter/blob/master/src/js/app/appHooks.service.js).