Can you force mobile emulation mode in Chrome via code?

I want to show my prototype app to a client via the browser.
I was going to get them to switch to mobile emulation mode in chrome dev tools and then turn on the device frame option so it looks like an iphone.

Is there a way I can force this in the code to tell chrome to open automatically in this mode?

Could you make use of ionic serve --lab

1 Like

I have just tried that and it works in development but if I deploy the contents of my wwwroot folder to my server it just has a 500 internal server error. (ionic build --prod works fine if deployed).
I need this to be deployed.

Any ideas?

Useful command to know though, thanks.

No that command is supposed to be used using the ionic web server. Might suggest you let the client run it in that fashion, or just offer some instructions.

I will just offer instructions. It would just have been nice to have it automatic as instructions are always problematic and I would have preferred the first time they see it to be in mobile format.


Just thinking about it, it’s a bit of an arse but if you have access to your firewall you could potentially share the ionic web server on port 8100. And give a direct link to your clients.

As long as you leave the ionic serve command running that might do it.

Fundamentally however, do they not want to see this running on an actual phone?

Yeah that would work. Bit to much of a hassle though as I want it up for a while.

Ha, yes using a phone to browse to the url is a good point. Honestly didn’t think of that until this morning. Can tell I’m new to mobile dev. I will give that as an option. The only issue with that is I have no control over the type of phone used and being a rough mock-up the formatting may be a bit messed up on some phones. With chrome I can fix it to a certain phone type.

If you mean actually deploying to a phone somehow, I am not at that stage yet as only just started with Ionic and I have only used xcode to do that so far. I would need a dev account with apple or android to deploy via the stores as far as I’m aware.

Anyway, all good to go, thanks for the suggestions.

How about an HTML file with an iframe? It would be easy to mock an iPhone with CSS.

Yeah that is a good idea. I had a quick search along that line for a phone image to use around the iframe and found this:

Looks pretty cool. I will give it a go next time I need to demo. Have completed my current demo now.

Thanks for the help.