How to make sure your application fit into all devices - Page 2 - Forum

Forum Navigation
You need to log in to create posts and topics.

How to make sure your application fit into all devices

PreviousPage 2 of 2

@luishp

when using neoDeviceGetInfo, I received information about the user's browser on a mobile device - unknow, while everything is fine from the desktop. Mobile browsers on iOS are not supported?
P S everything is fine on the Android emulator

@alexander_loc no idea sorry, I don't have any iOS device to test it.
Please use this link and let me know what results you get (it's using the original JavaScript library included with the plugin):

https://matthewhudson.github.io/current-device/

Regards.

@luishp Information about the device, operating system and orientation is displayed correctly, but I do not see information about the user's browser (Chrome, Safari, etc.)

@alexander_loc please unintall neoDevide and install the attached one.
Let me know if it works.

Thank you!

Uploaded files:
  • You need to login to have access to uploads.
alexander_loc has reacted to this post.
alexander_loc

@luishp

Thank you, now Safari is defined correctly, but for example, Bing browser, Yandex is also defined as Safari, and Chrome is defined as unknown. Is it possible to at least make sure that only Safari is detected, and other browsers are also unknown?

@alexander_loc this is the JavaScript function I'm using to detect the web browser. In Windows at least it seems to work correctly.
If you can find a better method I will be glad to update it, but I have not found a better one.

function getBrowserName() {
  const userAgent = navigator.userAgent;
  if (userAgent.indexOf("Firefox") !== -1) {
    return "Firefox";
  } else if (userAgent.indexOf("Edg") !== -1) {
    return "Microsoft Edge";
  } else if (userAgent.indexOf("Chrome") !== -1 && userAgent.indexOf("Edge") === -1) {
    return "Chrome";
  } else if (userAgent.indexOf("Safari") !== -1 && userAgent.indexOf("Chrome") === -1) {
    return "Safari";
  } else if (userAgent.indexOf("OPR") !== -1 || userAgent.indexOf("Opera") !== -1) {
    return "Opera";
  } else if (userAgent.indexOf("Trident") !== -1) {
    return "Internet Explorer";
  } else {
    return "Unknown";
  }
}

@luishp

let isSafari = navigator.vendor.match(/apple/i) &&
             !navigator.userAgent.match(/crios/i) &&
             !navigator.userAgent.match(/fxios/i) &&
             !navigator.userAgent.match(/YaBrowser/i) &&
             !navigator.userAgent.match(/edg/i) &&
             !navigator.userAgent.match(/Opera|OPT\//);

if (isSafari) {
  alert("Safari")
} else {
  alert("Other browser")
}

I found this method, checked it on all mobile browsers for iOS (Safari, FireFox, Opera, Chrome, Yandex, Edge). Since I only need to discover Safari for iOS to show the user instructions for installing PWA, otherwise I will be prompted to log in via Safari. That way worked for me. Maybe this should be added to the neoDevice plugin in order to detect safari for ios in order to install PWA? We will take the value true/false into a variable

@alexander_loc please check the attached plugin. I have added a new command: neoDevideIsSafari with your code.
Thank you!

Uploaded files:
  • You need to login to have access to uploads.
alexander_loc has reacted to this post.
alexander_loc

@luishp

Thank you Luis! Now the notification about the installation of PWA on iOS works perfectly!
Attached the result of my test application.
Together we need to make more solutions for mobile devices :)

Uploaded files:
  • You need to login to have access to uploads.
luishp has reacted to this post.
luishp
PreviousPage 2 of 2