Wed, 13 Jul 2022 08:21:53 GMT
Join the conversation at slack.cordova.io
Tue, 12 Jul 2022 19:51:09 GMT
@jessica says
hey all, does anyone know if there is a way to get the real user agent for the device, or if not, the iOS version and device name in a variable?
i'm trying to figure out what version of iOS my customers are using, and the user agent is coming in as
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148
no matter the device or iOS version
Tue, 12 Jul 2022 19:59:03 GMT
@norman137 says
Using the cordova-plugin-device plugin is probably the most reliable way, since it uses hardware APIs
Tue, 12 Jul 2022 20:01:44 GMT
@norman137 says
Are you sure you're not overriding the user agent via
OverrideUserAgent
preference?It's kinda odd that the user agent appears to be tampered with when you as the developer is the one that controls the webview settings that is in your app.
Tue, 12 Jul 2022 20:11:16 GMT
@jessica says
Hm, i didn‘t build this app personally but I am in charge of its development now. I just searched the codebase for
OverrideUserAgent
and didn’t find it.. what file would that normally be in?
Tue, 12 Jul 2022 20:11:46 GMT
@jessica says
I should note that someone else using ionic apparently has the same problem (that's me in the comments from a couple months ago): https://stackoverflow.com/questions/70747090/how-can-i-get-the-full-user-agent-in-sentry-dashboard
Tue, 12 Jul 2022 20:12:25 GMT
@jessica says
(I‘ve since found that it’s not a sentry issue specifically, our nginx logs show requests coming in with the user agent I pasted above)
Tue, 12 Jul 2022 20:17:54 GMT
@jcesarmobile says
Are you testing on iPhone or iPad? iPads have gotten browser user agents for a while now
Tue, 12 Jul 2022 20:18:14 GMT
@jessica says
My app is an iPad-only app
Tue, 12 Jul 2022 20:18:31 GMT
@jessica says
I tried with both a physical ipad and the ipad simulator and both sent that user agent i pasted above
Tue, 12 Jul 2022 20:18:42 GMT
@jessica says
the physical ipad is on ios 14 and the simulator was ios 15
Tue, 12 Jul 2022 20:18:48 GMT
@jcesarmobile says
Yeah, that’s it
Tue, 12 Jul 2022 20:19:30 GMT
@jcesarmobile says
You can set the app to load in “mobile mode”, that should change the user agent
Tue, 12 Jul 2022 20:19:40 GMT
@jessica says
oh? how is that done
Tue, 12 Jul 2022 20:20:26 GMT
@jcesarmobile says
<preference name=“PreferredContentMode” value=“mobile” />
Tue, 12 Jul 2022 20:20:45 GMT
@jcesarmobile says
It won’t work if you are using ionic webview plugin
Tue, 12 Jul 2022 20:21:34 GMT
@jessica says
i‘m not, i’m just using cordova. does this preference do anything else besides change the user agent? i‘m googling but it’s not immediately clear
Tue, 12 Jul 2022 20:22:20 GMT
@jcesarmobile says
It will load your app as a mobile device, some things change
Tue, 12 Jul 2022 20:22:51 GMT
@jcesarmobile says
It’s like when you are in safari and choose “load mobile version”
Tue, 12 Jul 2022 20:23:18 GMT
@jessica says
ok i've never tried that 😅 i will do some testing. thanks very much!
Tue, 12 Jul 2022 20:23:39 GMT
@jessica says
if it doesn‘t work, i’ll try the device plugin that norman suggested
Tue, 12 Jul 2022 20:25:39 GMT
@jcesarmobile says
Was added in cordova-ios 6.1.0, make sure you are in that version or newer one
Tue, 12 Jul 2022 20:26:26 GMT
@jessica says
yep i'm on cordova ios 6.2 🙂