-
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
feat: Add ability to override platform detection methods #19737
Labels
Milestone
Comments
liamdebeasi
added
package: core
@ionic/core package
type: feature request
a new feature, enhancement, or improvement
labels
Oct 23, 2019
This was referenced Jun 22, 2020
liamdebeasi
added
type: feature request
a new feature, enhancement, or improvement
and removed
type: feature request
a new feature, enhancement, or improvement
labels
Jul 16, 2021
13 tasks
willmartian
added a commit
that referenced
this issue
Sep 14, 2021
This feature has been added and will be available in the next beta release of Ionic Framework v6. 🥳 |
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. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
Feature Request
Ionic version:
[x] 4.x
Describe the Feature Request
The platform detection methods Ionic provides cover most use cases; however, it is not going to be possible for us to reasonably detect 100% of all devices correctly. This is particularly true for off brand Android devices that do not conform to a standard when it comes to identifying themselves on the web.
It would be good for us to allow users to override our own methods with their custom methods in case they need to handle those specific edge cases in their apps.
Describe Preferred Solution
The easiest way to do this is to let developers customize the
PLATFORMS_MAP
object: https://github.com/ionic-team/ionic/blob/master/core/src/utils/platform.ts#L118I see two options for doing this:
setPlatformDetection(platform: Platform, callback: any)
. This function will allow users to provide a platform and a detection function. Usage is as follows:(Note: The
any
type will be replaced with the appropriate function type once that is determined)After discussing with the team, I am leaning more towards option 2. I can see things getting a bit messy if users override the platform detection using option 1 after the app has already been initialized.
Additional Context
We might also want to consider exposing the
testUserAgent
andmatchMedia
functions that Ionic uses internally. I could see those being helpful when customizing the platform detection functions.The text was updated successfully, but these errors were encountered: