# Detecção de site móvel não deve depender do Safari no user agent

**URL:** <https://meta.discourse.org/t/mobile-site-detection-should-not-rely-on-safari-in-user-agent/103341>\
**Category:** Product Support\
**Created:** [Dezembro 3, 2018, 11:01am UTC](https://meta.discourse.org/t/mobile-site-detection-should-not-rely-on-safari-in-user-agent/103341 "2018-12-03T11:01:55Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![mekentosj](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mekentosj/32/125889_2.png) [@mekentosj](https://meta.discourse.org/u/mekentosj)\
**Post date:** [Dezembro 3, 2018, 11:01am UTC](https://meta.discourse.org/t/mobile-site-detection-should-not-rely-on-safari-in-user-agent/103341/1 "2018-12-03T11:01:55Z")

</div>

Hi all,

Thanks for the fantastic piece of software that Discourse is, it’s incredible!

We are using Discourse for the community of our app [Agenda](https://agenda.com), our users love it. This is in part because we built it straight in the app using a WKWebView on mac and iOS. Unfortunately this gives a problem on iPhones as apparently discourse fails to detect it’s running on mobile.

Compare the following screenshots taken from Mobile Safari (left) and Agenda (right) on the same device:

 ![45](https://global.discourse-cdn.com/meta/original/3X/e/6/e6f2a9f9a7b8c9c86ae917f06b6a11a9830e2d37.jpeg)

The issue seems to be caused by Discourse parsing the User Agent string (left mobile safari, right Agenda using a stock WKWebView) for the word Safari or the word Mobile:

If I indeed tell the WKWebView to set the custom user agent to the same string as mobile Safari it works correctly. Unfortunately this is not a really great solution as it would force us to spoof an incorrect user agent of an incorrect safari version etc. I hope this can be fixed (for example by also checking for the word iPhone)…

Thanks and keep up the great work!  
Alex

---

_[View the full topic](https://meta.discourse.org/t/mobile-site-detection-should-not-rely-on-safari-in-user-agent/103341)._
