Is there a way to block mobile users from opening ...
# compose-web
t
Is there a way to block mobile users from opening a website using compose web? for example if the user is on mobile show a dialog warning them that the website isnt optimized for mobile?
j
What is a mobile user?
An iPad with a sim card?
A phone in desktop mode?
My laptop tethered to my phone?
j
I used the following code to check whether it was a phone
Copy code
private val isMobile: Boolean
    get()  {
        val mobileKeywords = setOf("Mobile", "Android", "iPhone", "iPad", "iPod", "Windows Phone")
        return mobileKeywords.any { keyword -> window.navigator.userAgent.contains(keyword) }
    }
Maybe not ideal, but it is one way.
👍 1
t
Thanks, the reason im asking is because the website I made cant be navigated using a touch screen. I dont know if i messed up something or its because compose web is experimental. So for me a mobile user is a device with no mouse input only touch screen
j
What browser are you using? Are you using any sliders or just buttons? I had issues in scaling on Chrome, but it worked well on other browsers. However, after adding
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0"/>
to the head in the html-file it works okay on other browsers. However, I read that touch interfaces are still lacking because of experimental. I only use buttons, and it seems like it is more ready than dragging.
t
Thanks for the code it seems to have fixed the scaling issue. I tried google chrome on Android an its buggy but on duckduckgo it works. I cannot scroll on a lazy row but I have implemented navigation buttons so its not a big deal.
🙌 1