django-push-notifications icon indicating copy to clipboard operation
django-push-notifications copied to clipboard

Incompatibility with userAgentData.

Open dismine opened this issue 3 years ago • 5 comments

Hi.

I used loadVersionBrowser function from the documentation. And my view stopped working without producing any errors in logs. Later I figured out that it was caused by unexpected browser name. I use Vivaldi and userAgentData recognized it as Chromium, not Chrome as we expect, while old user agent string still claims that we are Chrome.

dismine avatar Dec 13 '21 15:12 dismine

The linked PR could also solve your issue. Could you try it?

simonkern avatar Dec 30 '21 12:12 simonkern

Hi.

I have tested your code. For Vivaldi the situation is the same. navigator.userAgentData returns Chromium. It correctly returns Chrome only when fallback to parsing a user agent string. In my case it is Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.113 Safari/537.36.

So, does it solve my issue? Kind of, yes. But why modern way to get a browser brand doesn't work with Chromium based browsers?

dismine avatar Dec 30 '21 13:12 dismine

if (brand.match(/opera|chrome|edge|safari|firefox|msie|trident/i) !== null)

This condition can never be true for the string "Chromium", which is why it should fallback to userAgent anyway. Are you sure the function returns "Chromium" as browsername?

"Chromium".match(/opera|chrome|edge|safari|firefox|msie|trident/i)
null

Vivaldi wouldn't be in the regexp anyway. Why they do not supply their browsername, like Edge does - I have no idea...

simonkern avatar Dec 30 '21 13:12 simonkern

Are you sure the function returns "Chromium" as browsername?

Your function returns Chrome. So, yes, it works correctly.

Vivaldi wouldn't be in the regexp anyway. Why they do not supply their browsername, like Edge does - I have no idea...

I can only guess.

dismine avatar Dec 30 '21 13:12 dismine

@dismine https://github.com/jazzband/django-push-notifications/pull/643 seems to have fixed your issue, can we close this?

jamaalscarlett avatar Feb 24 '22 04:02 jamaalscarlett