Reputation: 45
Is there a way how a script (bound to a Google sheet) can detect whether it is run on PC or on mobile?
The background to my question is that on a PC the class ui works. Therefore, prompts and alerts windows can be shown, and user input can be requested and processed, etc. On mobile, this is not possible. If the code can detect that it runs on mobile, then all user prompts can be avoided through simple if ( not run on mobile ) { } clauses.
Thank you very much!
Upvotes: 0
Views: 516
Reputation: 4430
At the moment, there is no possible way to detect if the script execution has been triggered by the desktop web UI or by a smartphone.
As a workaround, you can try using a try...catch
block around the code that prompts the user. If an exception is caught - it is because the code is being executed from a context that does not support prompting the user (i.e. from a smartphone) and this situation can be handled afterwards.
Upvotes: 1