Skip to content
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

bug: platform.is('tablet') returns true when running on an android phone device. #20200

Closed
davidperis92 opened this issue Jan 14, 2020 · 2 comments
Labels

Comments

@davidperis92
Copy link

davidperis92 commented Jan 14, 2020

Bug Report

Ionic version:
[x] 4.11.8

Current behavior:
platfrom.is('tablet') returns true when running on an android phone device

Expected behavior:
It should return true only when is runt on a tablet device.

Steps to reproduce:
Run an app that uses platform.is('tablet') on an android phone and watch the returned value of the function.

Related code:
File in github repository:
core/src/utils/platform.ts

const isAndroidTablet = (win: Window) => {
  return isAndroid(win) && !testUserAgent(win, /mobile/i);
};

const isMobile = (win: Window) =>
  matchMedia(win, '(any-pointer:coarse)');

If we look at this functions we can see that the "mobile" condition is checked in two different ways (with matchMedia and testUserAgent). When I run the app on a Mi phone device it returns true for platform.is('tablet') because testUserAgent(win, /mobile/i) returns false.

@ionitron-bot ionitron-bot bot added the triage label Jan 14, 2020
@davidperis92 davidperis92 changed the title bug: platform.is('tablet') returns false when running on an android phone device. bug: platform.is('tablet') returns true when running on an android phone device. Jan 14, 2020
@liamdebeasi
Copy link
Contributor

Thanks for the issue. I am going to close this in favor of #19737.

Due to inconsistencies between platforms and across devices, it is not easy to achieve a 100% success rate with platform detection. For example Android phones typically have mobile in their user agent string; however, a small number of Android phones do not.

We have opted instead to allow developers to override our platform detection methods with other methods that better suit an application's use case.

@ionitron-bot
Copy link

ionitron-bot bot commented Feb 13, 2020

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.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Feb 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants