Is there anyway to determine the OS of the device running a web deployment ?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Is there anyway to determine the OS of the device running a web deployment ?
I have converted a desktop app to a web app. I'm ecstatic about the results. It runs very well on Win, MacOS, iPhone, iPad, Linux and with all the browsers that I could find. But it doesn't run on Android's browsers. I say it doesn't run, that is not accurate. I have a login stack that accepts user id and password. The password field is hidden and "*"s are displayed as keydown events are used to build the actual password field. It may not be the best way to do this but it works on every other device/os/browser I have tried.
On Android the vertical "cursor" never moves, even though characters are added to the field. The "dummy" field with the "*"s is not visible, but the key strokes are. The keyboard starts acting strangely. Even if I manage to get the correct info into the userid and password fields, for some reason I can get the right information out of the fields to verify the user.
I am using LC fields. If there was a way to determine that the app is on an Android device, I am sure I can solve the problem. But, I don't see a way to get the OS name of the device the browser is running on. Have I missed some function that will return the OS name when deployed to "Web"?
Oh, I have never tried to use the "Android native field". What happens if you're not on an Android device if you use the Android Native Field?
You might have guessed that I'm not an Android guy.
Thanks for any help,
David Kesler
On Android the vertical "cursor" never moves, even though characters are added to the field. The "dummy" field with the "*"s is not visible, but the key strokes are. The keyboard starts acting strangely. Even if I manage to get the correct info into the userid and password fields, for some reason I can get the right information out of the fields to verify the user.
I am using LC fields. If there was a way to determine that the app is on an Android device, I am sure I can solve the problem. But, I don't see a way to get the OS name of the device the browser is running on. Have I missed some function that will return the OS name when deployed to "Web"?
Oh, I have never tried to use the "Android native field". What happens if you're not on an Android device if you use the Android Native Field?
You might have guessed that I'm not an Android guy.
Thanks for any help,
David Kesler
-
- VIP Livecode Opensource Backer
- Posts: 7257
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: Is there anyway to determine the OS of the device running a web deployment ?
Nothing, it doesn't work. But in this case I don't think it's needed anyway since you're building for a browser and those don't use native OS fields. It's all HTML. The default browser on Android is Chrome so I'd think it should work as it does on Chrome for desktop. Firefox is available on Android, you could try installing it from the Play Store and see if it behaves differently.Oh, I have never tried to use the "Android native field". What happens if you're not on an Android device if you use the Android Native Field?
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: Is there anyway to determine the OS of the device running a web deployment ?
It works on Chrome on Win10 and macOS. But not on any Android device that it has been tested on(3 Samsung phones, 2 Samsung tables, and a Pixel phone.)
I’ll try Firefox.
After I posted the question on the Android Native Field, I realized that it really was not a possibility that that would work.
Once I isolate the exact cause of the failure, at least at the LC level, I’ll post my findings and report a bug if one is loose.
Thanks,
David Kesler
I’ll try Firefox.
After I posted the question on the Android Native Field, I realized that it really was not a possibility that that would work.
Once I isolate the exact cause of the failure, at least at the LC level, I’ll post my findings and report a bug if one is loose.
Thanks,
David Kesler
-
- VIP Livecode Opensource Backer
- Posts: 135
- Joined: Tue Feb 23, 2010 10:53 pm
- Location: Saint Louis, Missouri USA
Re: Is there anyway to determine the OS of the device running a web deployment ?
I have been playing with a stack to answer the question of determining the OS of the device that requests a web app.
My stack may be a solution to the question. It asks the server to return the Browser's User Agent (a string sent by the device to the server).
The default User Agent string provided by the device usually contains a reference to the browser and an indication of the hardware.
Here are the strings from my Apple Macintosh laptop, my iPhone and my iPad:
Laptop:
In all three cases, the Safari browser is correctly identified near at the end of the strings.
Feel free to try out my stack at:
https://bobcole.on-rev.com/PlatformWeb/PlatformWeb.html
I'll leave the web app on my server for a while but I might remove it some time in the future.
I don't have any way to run this web app on Windows or Linux so other I'll have to leave it up to others to respond with their results.
It will be interesting to see if Android devices can be identified.
The stack is fairly simple (below).
Enjoy,
Bob
LiveCode 10.0.0-dp-3
MacOS 12.5 (Monterey)
MacBook Pro (Chip: Apple M1 Max)
Notes:
When using this stack in the IDE, the User Agent string may appear differently. For example, on my laptop, the string appears as: LiveCode (MacOS)
The stack does not work in a browser window when deployed with the Test menu or Test button in LC 10.0.0-dp-3 on my Mac laptop.
The stack does work after saving as a standalone app and moving it to a LiveCode enabled web server like on-rev.com (link above)
My stack may be a solution to the question. It asks the server to return the Browser's User Agent (a string sent by the device to the server).
The default User Agent string provided by the device usually contains a reference to the browser and an indication of the hardware.
Here are the strings from my Apple Macintosh laptop, my iPhone and my iPad:
Laptop:
iPhone:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.6 Safari/605.1.15
iPad:Mozilla/5.0 (iPhone; CPU iPhone OS 15_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.6 Mobile/15E148 Safari/604.1
I am surprised to see the Laptop and iPad report nearly the same User Agent string. The iPhone is clearly identified as distinct.Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.6 Safari/605.1.15
In all three cases, the Safari browser is correctly identified near at the end of the strings.
Feel free to try out my stack at:
https://bobcole.on-rev.com/PlatformWeb/PlatformWeb.html
I'll leave the web app on my server for a while but I might remove it some time in the future.
I don't have any way to run this web app on Windows or Linux so other I'll have to leave it up to others to respond with their results.
It will be interesting to see if Android devices can be identified.
The stack is fairly simple (below).
Enjoy,
Bob
LiveCode 10.0.0-dp-3
MacOS 12.5 (Monterey)
MacBook Pro (Chip: Apple M1 Max)
Notes:
When using this stack in the IDE, the User Agent string may appear differently. For example, on my laptop, the string appears as: LiveCode (MacOS)
The stack does not work in a browser window when deployed with the Test menu or Test button in LC 10.0.0-dp-3 on my Mac laptop.
The stack does work after saving as a standalone app and moving it to a LiveCode enabled web server like on-rev.com (link above)
-
- Livecode Opensource Backer
- Posts: 9444
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Is there anyway to determine the OS of the device running a web deployment ?
Hey-Ho, and Hello from my Samsung Galaxy:
Mozilla/5.0 (Linux; Android 11) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.134 Mobile Safari/537.36
This strikes me as a bit odd as I viewed your web app in the Brave browser.
What is clear is 'Android' . . . congratulations, this DOES detect Android phones.
Mozilla/5.0 (Linux; Android 11) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.134 Mobile Safari/537.36
This strikes me as a bit odd as I viewed your web app in the Brave browser.
What is clear is 'Android' . . . congratulations, this DOES detect Android phones.
Last edited by richmond62 on Wed Aug 03, 2022 11:14 am, edited 1 time in total.
-
- VIP Livecode Opensource Backer
- Posts: 9847
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Is there anyway to determine the OS of the device running a web deployment ?
How?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Is there anyway to determine the OS of the device running a web deployment ?
Thank you bobcole for giving my problem some thought and effort, I really appreciate it. Sooner or later others will need the strategy that you used to get the information.
Thanks to richmond62 for going to the trouble of verifying the Android response.
My plan is to use answer and password dialogs instead of normal fields. Hopefully it will work.
Thanks again to everyone.
David Kesler
Thanks to richmond62 for going to the trouble of verifying the Android response.
My plan is to use answer and password dialogs instead of normal fields. Hopefully it will work.
Thanks again to everyone.
David Kesler
-
- Livecode Opensource Backer
- Posts: 9444
- Joined: Fri Feb 19, 2010 10:17 am
- Location: Bulgaria
Re: Is there anyway to determine the OS of the device running a web deployment ?
And, as I am at present fooling around with a laptop running Xubuntu 22.04:
Mozilla/5.0 (X11; Linux x86_64; rv:103.0) Gecko/20100101 Firefox/103.0
Mozilla/5.0 (X11; Linux x86_64; rv:103.0) Gecko/20100101 Firefox/103.0
-
- Posts: 632
- Joined: Wed Apr 24, 2013 4:53 pm
- Contact:
Re: Is there anyway to determine the OS of the device running a web deployment ?
Code: Select all
do "result = navigator.platform;" as javaScript
answer the result
Similarly 'the processor' returns 'js' instead of more useful info such as the actual CPU type the web app is running on.
But you can get lots of that sort of info from the outer web page APIs using do tJS as javaSCript and then checking 'the result'
Code: Select all
do "result = window.navigator.userAgent;" as javaScript
answer the result
-
- VIP Livecode Opensource Backer
- Posts: 135
- Joined: Tue Feb 23, 2010 10:53 pm
- Location: Saint Louis, Missouri USA
Re: Is there anyway to determine the OS of the device running a web deployment ?
I implemented your two "do ... as javaScript" statements in the attached stack.
Running in the IDE, the platform shows as "MacOS" as expected on my Mac laptop.
Testing in a web browser, using LC's "the platform" shows as "web" and
Testing in a web browser, the "do ... as javaScript" platform shows as "MacIntel" (surprisingly).
Conclusion: be careful when determining which source of your platform variable to use.
Thanks for providing those examples!
Bob
Running in the IDE, the platform shows as "MacOS" as expected on my Mac laptop.
Testing in a web browser, using LC's "the platform" shows as "web" and
Testing in a web browser, the "do ... as javaScript" platform shows as "MacIntel" (surprisingly).
Conclusion: be careful when determining which source of your platform variable to use.
Thanks for providing those examples!
Bob
-
- VIP Livecode Opensource Backer
- Posts: 35
- Joined: Sat Jan 15, 2011 10:57 am
Re: Is there anyway to determine the OS of the device running a web deployment ?
Hello Bob
You can also use this link to see what gets reported by JavaScript.
On my macOS ARM mac some info is wrong eg. the platform and the system version ?
https://www.w3schools.com/jsref/tryit.a ... ef_nav_all
Cheers
Kangaroo
You can also use this link to see what gets reported by JavaScript.
On my macOS ARM mac some info is wrong eg. the platform and the system version ?
https://www.w3schools.com/jsref/tryit.a ... ef_nav_all
Cheers
Kangaroo
Re: Is there anyway to determine the OS of the device running a web deployment ?
First of all, thanks to everyone that has joined this tread. It has been most helpful.
Here are some of the things I have learned about the current implementation of Livecode html5 (10.0.0 dp4) while running on Android devices(at least the ones I have access to.)
1. The normal LC field does not work reliably with any browser I have tried, Chrome, FireFox, Opera, Opera-lite, or Brave. The keyboard does not display reliably, and the "insert cursor" has issues.
2. A work-around that I have employed is to determine that the browser is actually running on an Android device. Big thanks to bobcole for the idea to use $_SERVER["HTTP_USER_AGENT"]. I don't know where he found this in the documentation, I haven't been able to locate it(the _USER_AGENT part), but it works!
3. When the result of $_SERVER["HTTP_USER_AGENT"] contains "Android" then I use the Ask dialogs to fill the fields with the information needed. Unfortunately, some of the older Android versions, like "Lollipop", even the ask dialogs don't work very well.
4. I have put together a little app to test the native field and the Ask dialog. If you have a chance and have Android devices, please try this little app and save your result. I will compile the findings on the versions of Android that LC field/asks work. If you include your forum name when you save the information, I can thank all those that participated. I suspect there are variations with the different browsers also.
https://www.mnonation.com/android/testandroid.html
Thanks to everyone.
David Kesler
Here are some of the things I have learned about the current implementation of Livecode html5 (10.0.0 dp4) while running on Android devices(at least the ones I have access to.)
1. The normal LC field does not work reliably with any browser I have tried, Chrome, FireFox, Opera, Opera-lite, or Brave. The keyboard does not display reliably, and the "insert cursor" has issues.
2. A work-around that I have employed is to determine that the browser is actually running on an Android device. Big thanks to bobcole for the idea to use $_SERVER["HTTP_USER_AGENT"]. I don't know where he found this in the documentation, I haven't been able to locate it(the _USER_AGENT part), but it works!
3. When the result of $_SERVER["HTTP_USER_AGENT"] contains "Android" then I use the Ask dialogs to fill the fields with the information needed. Unfortunately, some of the older Android versions, like "Lollipop", even the ask dialogs don't work very well.
4. I have put together a little app to test the native field and the Ask dialog. If you have a chance and have Android devices, please try this little app and save your result. I will compile the findings on the versions of Android that LC field/asks work. If you include your forum name when you save the information, I can thank all those that participated. I suspect there are variations with the different browsers also.
https://www.mnonation.com/android/testandroid.html
Thanks to everyone.
David Kesler
-
- VIP Livecode Opensource Backer
- Posts: 135
- Joined: Tue Feb 23, 2010 10:53 pm
- Location: Saint Louis, Missouri USA
Re: Is there anyway to determine the OS of the device running a web deployment ?
David:From: djkesler
2. A work-around that I have employed is to determine that the browser is actually running on an Android device. Big thanks to bobcole for the idea to use $_SERVER["HTTP_USER_AGENT"]. I don't know where he found this in the documentation, I haven't been able to locate it(the _USER_AGENT part), but it works!
Open the LiveCode dictionary and look for $_SERVER.
I have a file on my server (at on-rev LiveCode Hosting) that loops through the $_SERVER array and returns each line.
You can try it out here: https://morrevbon.com/listVars.lc
I'm glad you got your application to work!
Bob
Here are the contents of that file:
Code: Select all
<?lc
command outputRow pLabel, pValue
?>
<tr>
<td>
<b>
<?lc put pLabel ?>
</b>
</td>
<td>
<?lc put pValue ?>
</td>
</tr>
<?lc
end outputRow
?>
<html>
<body>
<table>
<?lc
repeat for each key tKey in $_SERVER
outputRow tKey, $_SERVER[tKey]
end repeat
?>
</table>
</body>
</html>
-
- VIP Livecode Opensource Backer
- Posts: 7257
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: Is there anyway to determine the OS of the device running a web deployment ?
It also returns the wrong system version for me, I'm running OS 12 (Monterey.) So I found this:Kangaroo SW wrote: ↑Sat Aug 20, 2022 7:56 amYou can also use this link to see what gets reported by JavaScript.
On my macOS ARM mac some info is wrong eg. the platform and the system version ?
https://www.w3schools.com/jsref/tryit.a ... ef_nav_all
https://stackoverflow.com/questions/649 ... os-big-sur which basically says it's a bug in the reporting agent.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
-
- VIP Livecode Opensource Backer
- Posts: 7257
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: Is there anyway to determine the OS of the device running a web deployment ?
I sent four reports, using two devices and two Android keyboards. The results on your app duplicate my own experience in a web app I've built. Since there wasn't much space to type, in brief I'll summarize here:
SwiftKey normally auto-types spaces after you choose a suggested word. It also allows you to type spaces from the keyboard. On mobile, spaces never worked with either method so all words ran together. In fact, no keyboard entries were recognized at all, the only way to enter text in the field was to choose an auto-suggestion. Punctuation also could not be entered since that requires keyboard entry. The cursor appeared at the correct location however. (Since SwiftKey has so many preferences, different settings might have changed these results. This is my preferred keyboard because it literally thinks for you after it acquires enough info about how you write, so I didn't want to change it.)
On GBoard spaces and letters could be typed, but after a space the next word was auto-capitalized. To type a lower case letter you have to toggle the shift key twice. The cursor was misaligned, and appeared at the beginning of a word even though keyboard entries were added after it. Since I rarely use this keyboard it was using default settings.
The results were the same on both my old tablet and my new phone. In all four tests, the answer dialog worked normally and allowed normal typing, and auto-suggestions worked as you'd expect.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com