This question has been debated several times, so let me lay out the problem and see if I can get a clear and modern answer.
I have a file upload component, on a page, that will preview the file prior to ever sending it to the server. It supports multiple file types, including multiple image formats and pdf. I have 'alternative' views for certain scenarios, like 'tif' files can only natively be displayed in Safari.
My issue is embedding a PDF file. I have this working, no problem. Except in mobile. Mobile browsers don't support embedding PDF's.
So here's the core issue. I can display alternative text, with a download link. But I only want to do this in mobile browsers. I can't use media queries here, as this isn't really a screen size thing (and my core audience uses old, small desktop screens in clinic scenarios, which are about the size of a tablet in landscape mode).
I could use a UserAgent parsing approach, but these change, and browser support is shifting.
Then there's feature detection, but what works? Detecting touch support can be problematic.
So, what is the best approach for this scenario?