Ionic-framework: Platform is always "mobile" (instead of "mobileweb") if you `ionic build browser`

Created on 8 May 2017  路  9Comments  路  Source: ionic-team/ionic-framework

Ionic version: (check one with "x")
[ ] 1.x
[ ] 2.x
[x] 3.x

I'm submitting a ... (check one with "x")
[x] bug report
[ ] feature request

Current behavior:
Platform always contains mobile instead of mobileweb when you build your app using ionic build browser, no matter if the app is actually running in an app or in the browser.

Reason is that currently the existence of Cordova is taken as an indicator for mobile:
https://github.com/driftyco/ionic/blob/5d562166fcc648dd42b6e7415b2f267e8f7ac141/src/platform/platform.ts#L1004-L1006

See more discussion on this here:
https://forum.ionicframework.com/t/how-to-determine-if-browser-or-app/89149

Expected behavior:
If the Ionic app is running in the browser, it should contain "mobileweb" in Platform no matter how I build it.

Steps to reproduce:
https://github.com/beck24/ionic-platform-test
https://beck24.github.io/

Most helpful comment

Workaround the user found:

this.isApp = !document.URL.startsWith('http');

All 9 comments

Workaround the user found:

this.isApp = !document.URL.startsWith('http');

Hello, thanks for using Ionic. This is something we will look into, but currently, we do not really recommend using the cordova browser platform as it is still a work in progress.

Hello! I am going to close this issue as we are going to start officially recommending users do not use the cordova browser platform (issue for ref https://github.com/driftyco/ionic-site/issues/1106). The cordova browser platform was originally built as an experiment from the cordova team and was really meant to be used by plugin developers only. Because of this it causes all kinds of issues when trying to use it as an actual production platform and is why we are going to start officially recommending people not use it. Thanks!

@jgw96 cordova-browser v5 has been released. Any idea when Ionic will officially support the browser platform? I've been using it in my app for awhile (even before v5) and I haven't had any issues (other than this one).

Did v5 of cordova-browser substantially improve on the mentioned issues?

@jgw96 And how are we supposed to build PWAs and hybrid apps with Ionic and sharing the same code? Isn't this the whole point of using Ionic??

I've got the same problem. This makes no sense i regards to being able to create a PWA

@cdelgadob for PWA use
ionic build --prod --release and use the www folder.

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

Was this page helpful?
0 / 5 - 0 ratings