Skip to content

V14 - ExtendedClientDetails isIPad method does not work #14517

Closed

Description

@paodb

Description of the bug

In Vaadin 14, trying to use ExtendedClientDetails#isIPad() to detect an Ipad device always returns false.

Expected behavior

ExtendedClientDetails#isIPad() should return true if used device is Ipad.

Minimal reproducible example

ui.getPage().retrieveExtendedClientDetails(details -> {
      boolean isIPadValue = details.isIPad();
      Notification.show(isIPadValue ? "ipad" : "not ipad");
});

Versions

  • Vaadin / Flow version: 14.8.15
  • OS version: 9th generation iPad running iOS 15.4 & iPad Air 2 running iOS 15.5

Activity

  1. mcollovati commented on Sep 14, 2022

    @mcollovati
    Collaborator

    Hi @paodb,
    can you please post the client request related to the retrieveExtendedClientDetails?

    It should be something like the following

    image

    isIpad() checks for v-np to start with iPad
    If the value is null, it delegates the check to VaadinSession.getCurrent().getBrowser(), with the following condition
    browser.isIPad() || (browser.isMacOSX() && isTouchDevice())

  2. mcollovati commented on Sep 14, 2022

    @mcollovati
    Collaborator

    Tested with an IPad Air 2 (iOS 15.6.1) and can replicate the issue.
    It seems like that v-np value is MacIntel

    {
       "v-sh":"1024",
       "v-sw":"768",
       "v-wh":"665",
       "v-ww":"1024",
       "v-bh":"729",
       "v-bw":"1024",
       "v-curdate":"1663160988202",
       "v-tzo":"-120",
       "v-dstd":"60",
       "v-rtzo":"-60",
       "v-dston":"true",
       "v-tzid":"Europe/Rome",
       "v-wn":"ROOT-2521314-0.9113661870159819",
       "v-td":"true",
       "v-pr":"2",
       "v-np":"MacIntel"
    }
  3. johannest commented on Sep 14, 2022

    @johannest
    Contributor

    This js snippet seems to work for now, but no guarantee how long before Apple changes something

    window.is_ipad = function() {
        return (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 0) || navigator.platform === 'iPad';
    };
    
  4. mcollovati commented on Sep 14, 2022

    @mcollovati
    Collaborator

    A solution can modify ExtendedClientDetails.isIpad be to always delegate to WebBrowser checks if navigatorPlatform does not start with iPad (that basically is the same as the proposed workaround, but done server side)

    Original check

       public boolean isIPad() {
            if (navigatorPlatform != null) {
                return navigatorPlatform.startsWith("iPad");
            }
            WebBrowser browser = VaadinSession.getCurrent().getBrowser();
            return browser.isIPad() || (browser.isMacOSX() && isTouchDevice());
        }

    Potential change

        public boolean isIPad() {
            if (navigatorPlatform != null && navigatorPlatform.startsWith("iPad")) {
                return true;
            }
            WebBrowser browser = VaadinSession.getCurrent().getBrowser();
            return browser.isIPad() || (browser.isMacOSX() && isTouchDevice());
        }
  5. self-assigned this
    on Sep 14, 2022
  6. mcollovati commented on Sep 15, 2022

    @mcollovati
    Collaborator

    So, it seems that for iPad and iOS 15 all we can do is assume that if navigatorPlatform is MacIntel and it is a touch device, it is an iPad.
    This should work for now, but may not be enough in the future.
    Of course, we should also preserve the check for startsWith(iPad)

  7. mcollovati commented on Sep 15, 2022

    @mcollovati
    Collaborator

    Related issue: #14133

  8. added 3 commits that reference this issue on Sep 15, 2022
    4b4f028
    4f6f9c5
    18e263b
  9. added 2 commits that reference this issue on Sep 19, 2022
    05cbfd0
    0484db8
  10. added 2 commits that reference this issue on Sep 19, 2022
    6ee7a73
    60c474b
  11. vaadin-bot commented on Sep 26, 2022

    @vaadin-bot
    Collaborator

    This ticket/PR has been released with Vaadin 14.8.18.

  12. vaadin-bot commented on Oct 3, 2022

    @vaadin-bot
    Collaborator

    This ticket/PR has been released with Vaadin 23.3.0.alpha1 and is also targeting the upcoming stable 23.3.0 version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions