How to determine device in Web 2.0

We could determine what device a session was on but now with Web 2.0 that seems to have disappeared. Now we can see that the operating system is iOS but not whether it’s a desktop or iPad. The difference can be important.

Does anyone know how to determine what device a session is on in Web 2.0?

Try adding this to session. You get the browser headers.

Sub Opening() Handles Opening
  messagebox session.RawHeaders
End Sub

Apparently I cannot paste the code now to create the event handler. So you have to create the event manually.

the raw header includes the operating system, but not the device

Host:127.0.0.1:8080
Connection:keep-alive
sec-ch-ua:Google Chrome;v=107,Chromium;v=107,Not=A?Brand;v=24
sec-ch-ua-mobile:?0
sec-ch-ua-platform:Windows
Upgrade-Insecure-Requests:1
User-Agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML,like Gecko) Chrome/107.0.0.0 Safari/537.36
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,/;q=0.8,application/signed-exchange;v=b3;q=0.9
Sec-Fetch-Site:none
Sec-Fetch-Mode:navigate
Sec-Fetch-User:?1
Sec-Fetch-Dest:document
Accept-Encoding:gzip,deflate,br
Accept-Language:en-GB,en-US;q=0.9,en;q=0.8

Right, I can get Safari and iOS but not whether it’s on a desktop or iPad

Can you paste me IOS and OSX headers please? They usually contain enough info to work it out.

if you can explain something. I program on Windows and only test on iOS and iPad. Can I get the header to show up on Windows somehow?

I don’t know what you mean. When the browser accesses the web app it’s headers are captured. I saved them in the session and put them in a textarea on the webpage once it opened.

You could access them from your “messages” tab if you “Print” the headers out.

Launch the debug web app on Windows and connect to it with your iPad, with its URL: 192.168.1.11:8080 (replace 192.168.1.11 with the IP of the Windows computer and 8080 with the chosen port in Xojo).
Then, when the iPad connects, you’ll get the same debug context.

Determining the device type was used by advertisers to track users, so Apple no longer announces device type in the User Agent string starting with iOS 13.

You will need to look at the page dimensions and make your layout determination that way.

1 Like

That’s unfortunate because showing a pdf in an html viewer on the iPad isn’t working, but showing it in a new window is.

This could be resolved (Kinda) by creating a way for users to remain logged in . . . Nothing hey enter is important, but the clients shouldn’t access to each other’s files

It sounds like your actual problem is that you aren’t able to consistently display a PDF?
Try this workaround (via @Martin_T in another thread)

var url as String = "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"
HTMLViewer1.LoadURL("https://drive.google.com/viewerng/viewer?embedded=true&url=" + url)

Better way to PDF:

I have a html viewer on a webpage, w as webfile property, with a button with this code:

dim f as new FolderItem(“c:\users\daniel\downloads\dummy.pdf”)
w = new WebFile
w = webfile.Open(f)
w.ForceDownload=false
w.MIMEType = “Application/PDF”
HTMLViewer1.LoadURL(w.URL)

Does not need to be online to work and provides pdf controls. Works in desktop with a html viewer as well.

1 Like

Works great on a desktop. Doesn’t work at all on an iPad

hahah safari is aids

What would you use as your smallest desktop screen size?

1920x1080 is generally going to be about the smallest nowdays.

That the resolution not the screen width and height isn’t it?