Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DOC] Add prod / dev switch scenario #23

Open
vogloblinsky opened this issue Jul 8, 2018 · 3 comments
Open

[DOC] Add prod / dev switch scenario #23

vogloblinsky opened this issue Jul 8, 2018 · 3 comments

Comments

@vogloblinsky
Copy link

Hi,

Thanks for these useful mocks.

Could you add in the main README an explanation about how we can disable mock in production mode ?

//AOT trick
let checkDevMode = false;
if (isDevMode()) {
  checkDevMode = true;
}
const CameraConfiguration = (checkDevMode) ? { provide: Camera, useClass: CameraMock } : Camera;

providers: [
    ...,
    CameraConfiguration,
    ...
]
@asofyan
Copy link

asofyan commented Jul 12, 2018

I think this approach is better. You don't have to change it every time you build your app:

const isBrowser = document.URL.includes(‘https://’) || document.URL.includes(‘http://’);/*document.URL.startsWith(‘http’);

and then a bit lower in the provides :

(isBrowser ? {provide : Camera, useClass : CameraMock} : Camera),
(isBrowser ? {provide : ImagePicker, useClass : ImagePickerMock} : ImagePicker),
(isBrowser ? {provide : Geolocation, useClass : GeolocationMock} : Geolocation),

@chrisgriffith
Copy link
Owner

Thanks. I will add this to the Read Me shortly.

@sebinpj
Copy link

sebinpj commented May 9, 2019

const isBrowser = document.URL.includes(‘https://’) || document.URL.includes(‘http://’);/*document.URL.startsWith(‘http’);

Your approach doesnt work i logged this and it always returned true . and ionic seems to be running in the localhost in a mobile device

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants