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

feat: How to detect like code is running into ios or android or normal browser #20776

Closed ipehimanshu closed 4 years ago

ipehimanshu commented 4 years ago

Hello sir

i am using latest ionic 5,

we need to detect like code is running for browser (any like android or ios or desktop), or android as apps or ios apps,

Can you please help me to solve this.

Thanks

liamdebeasi commented 4 years ago

Thanks for the issue. Please see: https://ionicframework.com/docs/angular/platform.

ipehimanshu commented 4 years ago

@liamdebeasi below link not help much more https://ionicframework.com/docs/angular/platform

because we need to identify like Code running in app as ipk or app as ipa or run as browser ( it run into desktop or mobile browser).

Got my point ?

see below our ionic 3 code if (this.platform.is('core') || this.platform.is('mobileweb')) { this.common.device_type = 'browser'; } else { if (this.platform.is('ios')) { this.common.device_type = 'ios'; } else if (this.platform.is('android')) { this.common.device_type = 'android'; } }

Possible to share any demo code which works same like above into ionic 5

Thanks in advance

liamdebeasi commented 4 years ago

The Platform dependency injection in Ionic 5 is exactly the same as the Platform dependency injection in Ionic 3 (plus a few bug fixes). The code you have in Ionic 3 should work fine in Ionic 5.

ipehimanshu commented 4 years ago

@liamdebeasi But sir this code give error this.platform.is('core')

liamdebeasi commented 4 years ago

Can you provide a repo with the code required to reproduce this issue?

ionitron-bot[bot] commented 4 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.