ionic-team / ionic-framework

A powerful cross-platform UI toolkit for building native-quality iOS, Android, and Progressive Web Apps with HTML, CSS, and JavaScript.
https://ionicframework.com
MIT License
51.07k stars 13.51k forks source link

Platform is always "mobile" (instead of "mobileweb") if you `ionic build browser` #11557

Closed janpio closed 7 years ago

janpio commented 7 years ago

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/

janpio commented 7 years ago

Workaround the user found:

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

jgw96 commented 7 years ago

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.

jgw96 commented 7 years ago

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!

soumak77 commented 7 years ago

@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).

janpio commented 7 years ago

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

cdelgadob commented 6 years ago

@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??

yunderboy commented 6 years ago

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

amreladawy commented 6 years ago

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

ionitron-bot[bot] commented 6 years ago

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.