-
Notifications
You must be signed in to change notification settings - Fork 13.5k
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
Platform is not showing enough information about platform names #13267
Comments
Hello! Thank you for opening an issue with us! We do not suggest using the Cordova browser platform. Rather, we suggest not using Cordova at all for web installations. If your code base supports both Native iOS/Android builds and web builds, we suggest using web API calls when in web rather than trying to use Cordova plugins. See the "plugins" section of the following document for details: https://ionicframework.com/docs/developer-resources/desktop-support/ Here is a good resource for what you can do from web APIs to avoid having to use plugins: https://whatwebcando.today/ For deployment on the web, we suggest doing Thank you for using Ionic |
Thank you for reply. I understand your point. In fact I am facing CSS issues also. Instead of: The app looks fine on development using ionic serve but once deployed to the web server there are some minor CSS differences in main.css. One of the benefits of using Ionic is the chance to manage a single code base for different platforms. I know that to follow your approach I will need to remove all plugins, cordova.js from index and all imports for PWA. Then use web api to replace cordova plugins funciontality. Instead of creating two different projects, using cordova plugins or web api in code, and run different build commands for each case (web or native), is there any way to have one single code base and manage this situation? Thanks for your support. Best regards, |
@kensodemann , whether or not you "suggest" using the Cordova browser platform, calling A small number of the Ionic Native plugins do have In my case, we are building a mobile app that uses a QR Code scanner Cordova plugin that does have a browser platform implementation (uses webcams to scan the QR codes.) We use Cordova browser platform builds, not for production use by the public, but to demonstrate the use of the product in presentations and conference calls. This actually works well, but there are other areas of the app where we need to detect if we are in this environment in the browser platform in order to disable certain incompatible things. It would be very simple to do this if the call to |
@pablo-gonzalez - responding to this:
We do not suggest creating two different projecst or having two different code bases or anything like that. The this.platform.ready()
.then(() => {
if(this.platform.is('cordova')) {
// make your native calls
} else {
// handle thing accordingly
}
}) That only leaves the inclusion of |
@kensodemann I had read that documentation before and the forums. If you accept a suggestion I would include in Ionic documentation the build command for PWA: I have read questions about how to manage the build process when you are working with PWA and native code. I guess that there is some way to manage it with scripts but commenting the lines in index is not a big deal.
Please correct me if I am wrong. Thank you very much, |
We have a blog post that addresses a lot of those questions: https://blog.ionic.io/how-to-make-pwas-with-ionic/
For instances like that, I would:
I probably wouldn't go with something like #3 unless I absolutely had to though. I hope that made some sense. |
I had read that blog before and it covers very well the build process only for PWA. Again thank you very much for your support and guidance. I love IONIC! 🥇 |
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. |
Ionic version: (check one with "x")
(For Ionic 1.x issues, please use https://github.com/ionic-team/ionic-v1)
[ ] 2.x
[x] 3.x
[ ] 4.x
I'm submitting a ... (check one with "x")
[ x] bug report
[ ] feature request
Please do not submit support requests or "How to" questions here. Instead, please use one of these channels: https://forum.ionicframework.com/ or http://ionicworldwide.herokuapp.com/
Current behavior:
I am using a single code base for browser (PWA) and Android platforms.
When deploying a PWA using browser platform the Platform.platforms() method is showing "cordova mobile android". Same output when running the Android apk.
Expected behavior:
In this particular case I am using a cordova plugin available for Android (not browser) to show Music Controls when playing audio.
Thus when I am using PWA I would like to use MediaSession Web API instead.
I would expect some information from Platforms to choose the correct implementation.
Steps to reproduce:
Create a Ionic 2 project
Add Android and browser platforms
Import Platform somewhere in your code, declare some variable for that and then add for instance:
console.log('platforms', platform.platforms());
ionic cordova run android -lc
Later
ionic cordova browser --prod
Deploy the PWA to a web server and access URL of the webapp using Chrome Android browser in your device. Inspect the console.
The ouput for both cases will be "cordova, mobile, android"
However if you run the PWA using ionic serve on localhost:port you will see in your desktop browser console the output is "cordova, core".
However if you configure port forwarding, access localhost:port using your Chrome Android browser in your device and then Inspect the console you will get "mobile, android, mobileweb"
Related code:
Other information:
I think this issue could be related to this request:
#12582
Ionic info: (run
ionic info
from a terminal/cmd prompt and paste output below):The text was updated successfully, but these errors were encountered: