I tried this (Page Not Found — Xojo documentation) and that
but both failed and i don’t know what i do wrong.
Using my iphone 6s plus and i got “Macintosh”, instead of iPhone… The secong gives “Unknown”!
Anyway to compare width and height screen size and use it instead of platformtype ?
Select Case Session.Platform
Case WebSession.PlatformType.AndroidPhone
MsgBox("AndroidPhone")
Case WebSession.PlatformType.AndroidTablet
MsgBox("AndroidTablet")
Case WebSession.PlatformType.iPhone
MsgBox("iPhone")
Case WebSession.PlatformType.Macintosh
MsgBox("Macintosh")
Case WebSession.PlatformType.Windows
MsgBox("Windows")
Case WebSession.PlatformType.Unknown
MsgBox("Unknown platform type")
End Select
Dim p As WebSession.PlatformType = session.Platform
If p = WebSession.PlatformType.AndroidPhone Or p = WebSession.PlatformType.iPhone Then
msgbox("Mobile enable")
End If
I did a test, a webapp with only a label. In the label open event I put you Select Case code and it works, for my mac it say Macintosh and for my phone it say AndroidPhone.
Note: first I changed MsgBox to Me.Text, and the label shown the correct information. Then run it as is, and it shows the correct MsgBox. Don’t have an iPhone right now, but I could test later.
[quote=407423:@Michael Batakis]But using an iPhone, this is exactly the problem, I got MAcintosh insteadof iPhone.
I use Windows7 Chrome Xojo2018.2[/quote]
The problem is that the web framework currently uses user-agent parsing to figure out what the device is. If Apple has changed that string drastically (and they do from time to time) it should be that theyre no longer indicating that its an iOS device.
And the user agent strings for mobile Safari have not changed enough to cause this issue.
If you go to that page on the device thats giving you trouble, scroll down to the section that says YOUR WEB BROWSER’S USER AGENT: and paste the value here.
I guess Safari will show as iPhone and Chrome will show as Macintosh, right?
I’m sorry I can’t help you more. I think the browser does not send the screen resolution so you may need to execute some javascript to get your visitor’s browser resolution: https://www.w3schools.com/jsref/prop_screen_width.asp
Anyway I manage to solve it:if I got Macintosh and Self.height>Self.Width then it is an iPhone!
However, I tried the Javascript things. As I was looking in related posts, there is a bit tricky of how to get a returned value. Is it so difficult Xojo to implement using Xojo.Trigger.Event a function to get easily a returned javascript value? I’m just curious, as I think that it is highly important the user to be able to use Javascript in a proper way and get easily the return value…
I m thinking like that:
Using DOM’s , could a user use a Javascript to set it with the returned Javascript value and then using xojo to read the WebPage.HelpTag (or another’s control) so to get the returned Javascript value and use it accordingly? Or like something that, if you get what i mean (don’t be familiar with them . just a thought)
[quote=407943:@Michael Batakis]I m thinking like that:
Using DOM’s , could a user use a Javascript to set it with the returned Javascript value and then using xojo to read the WebPage.HelpTag (or another’s control) so to get the returned Javascript value and use it accordingly? Or like something that, if you get what i mean (don’t be familiar with them . just a thought)[/quote]
You might as well use the WebSDK. Its set up to let you do communications like that.
The WebSDK Documentation can be found in Xojo/Extras/WebSDK/ - you must be familiar with HTML/Javascript to understand it.
You may find a tool I made of some use, it creates empty WCW classes with a bunch of the basics filled in: http://webgen.timi.me
Thanks Tim, I can understand the code but I mentioned the above, just wondering why Xojo have not implemented an internal command to get returned Javascript values easily… It is supposed that most users of Xojo are not familiar with javascript and Html (otherwise they could make an app using only javascript and html having more flexibility in their projects).
Never mind…
Thank you again
PS: I have bought the “I Wish I Knew How To… Program HTML, CSS, and JavaScript with Xojo”… very useful!