cheeaun / hackerweb

A simply readable Hacker News web app
http://hackerwebapp.com/
1.23k stars 133 forks source link

iPhone SE (2020) defaults to 'web' theme. #66

Closed Leftium closed 3 years ago

Leftium commented 3 years ago

The iPhone SE (2020) defaults to the 'web' theme (only) on https://hackerweb.app.

For some reason the iPhone gives a different user agent for https://hackerweb.app: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.3 Safari/605.1.15

The same device/browser gives the expected user agent for other domains like https://hackerweb.leftium.com: Mozilla/5.0 (iPhone; CPU iPhone OS 14_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.3 Mobile/15E148 Safari/604.1

So the userAgent check is failing to detect the iPhone. I'm not sure if something can be changed on the server side or in the detection code to solve this. Maybe it's just a weird Safari bug, but I'm not sure why it only happens on https://hackerweb.app. https://hackerweb.leftium.com is simply a clone of https://github.com/cheeaun/hackerweb hosted on Netlify.

Interestingly, the 'web' theme on an iOS device actually works better in some ways:

image image

captn3m0 commented 3 years ago

Is this on Safari?

Leftium commented 3 years ago

Is this on Safari?

Yes, stock iOS Safari.

cheeaun commented 3 years ago

Hmm this looks weird. Few things to try:

  1. Check if you tapped on 'Request Desktop Website' on Safari?
  2. Is this on the browser or after added to the Home Screen (as PWA)?
  3. Can you try this on Safari's incognito/private mode?
Leftium commented 3 years ago

Interesting~

Check if you tapped on 'Request Desktop Website' on Safari?

I did not tap on 'Request Desktop Website,' but it was already in desktop mode. 'Request Mobile Site' results in the iOS theme. No matter which mode I leave it in, 'Clear History and Website Data' always resets it to desktop mode.

Is this on the browser or after added to the Home Screen (as PWA)?

From the browser. I just tried adding it to Home Screen, and it's in desktop mode, with no way to switch.

Can you try this on Safari's incognito/private mode?

Private mode results are exactly the same.

I wonder if Safari is treating the site differently because of the ".app" TLD.

cheeaun commented 3 years ago

@Leftium can you try tap on Website Settings and check if Request Desktop Website is turned on?

Leftium commented 3 years ago

can you try tap on Website Settings and check if Request Desktop Website is turned on?

Not sure what you are asking. I already tried both Request Desktop Website and Request Mobile Website via the "aA" menu in the left of the address bar in previous comment:

The problem is https://hackerweb.app, and only this domain, defaults to desktop mode after clearing Safari's data via Clear History and Website Data. I verified this by clearing the data for these cases:

Note this is only for an iPhone SE 2020; an iPhone 5 behaves as expected, and I don't have any other iOS devices to test.

Let me know if I misunderstood what you were asking. It's not a big deal, but I am just curious why this is happening...

cheeaun commented 3 years ago

Sorry, I meant this:

Leftium commented 3 years ago

Can you try tap on Website Settings and check if Request Desktop Website is turned on?

Oh, I see what you mean now! There is another Request Desktop Website there, and Clear History and Website Data does not reset this setting.

Now https://hackerweb.app works as expected!