Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / [SOLVED] GetAppPlatform() ?

Author
Message
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 16th Mar 2020 03:05
i need to detect whether or not my app is running in a browser (while i plan on exporting for windows, android and HTML5).

using the GetDevice() commands won't accomplish that (that i can see) where it could be running in a browser on a windows or android device and i see that GetAppName() states that it (only) returns the name of the exe (IE, only useful on Windows) while i was hoping to check the app file extension to "detect" when i saw the command.

i've perused a number of other commands that might have helped and saw nothing that will dial this in for me. IE, SharedVarible commands state they run on Android (outside of a browser) so i can't use that to test.

i'd rather not code separate apps for each platform and prefer using something like:



have i missed something obvious or can anyone think of a work-around?

The author of this post has marked a post as an answer.

Go to answer

blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 16th Mar 2020 04:15
I'm just guessing but maybe GetDeviceBaseName() in combination with CountWindowsDrives()
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 16th Mar 2020 05:27 Edited at: 16th Mar 2020 05:53
Uploaded this:

here: https://virtual-nomad.itch.io/ishtml
from windows and android browsers:


The AppName$ shows in Windows & as APK & when Broadcast to Android. So, i expect:


can others please test and respond? is this the easiest way to detect if it's being run in a browser?

ADD: i had the IsHTML.txt outside of the media folder on first go. re-upped and is showing 1 so is an option for detection (including an html-only file).

Attachments

Login to view attachments
Bengismo
6
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 16th Mar 2020 13:05
According to the source ....Both GetDeviceName() and GetDeviceBaseName() return "html5" when running in a browser.
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 16th Mar 2020 20:27 Edited at: 16th Mar 2020 20:28
I don't see "html5" in that documentation at all.
Bengismo
6
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 16th Mar 2020 20:31 Edited at: 16th Mar 2020 20:42
I said according to the source...as in, the source code...

Also...in the build notes for Build 2.0.19
Quote: "GetDeviceName will now return "html5" on HTML5"


The documentation has never been updated to reflect that.
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 16th Mar 2020 20:54
This post has been marked by the post author as the answer.
It does work for html5. You should note that GetDeviceName() doesn't work for studio so GetDeviceBaseName() is probably the best bet
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 20th Mar 2020 21:29 Edited at: 20th Mar 2020 21:30
thanks, guys. i'm going with GetDeviceBaseName() which is working as desired.

i've also emailed request for updates to both help files to include "html5".

forward. always forward!

Login to post a reply

Server time is: 2024-03-28 14:25:59
Your offset time is: 2024-03-28 14:25:59