Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
iOS8 Beta Phonegap fix: manually set the navigator.userAgent
// temp fix for iOS8 beta 1 (fixed in beta 2), add it after the reference to cordova.js
if (navigator.userAgent === undefined) {
navigator.__defineGetter__('userAgent', function() {
return("Mozilla/5.0 (iPhone; CPU iPhone OS 8_0 like Mac OS X) AppleWebKit");



It didn't work for me. The application loads but it looks messy/disordered because the css never loads. Trying to find an alternative.. if there is any other option or proposal i would be glad to hear it. Thanx..


EddyVerbruggen commented Jun 7, 2014

@JcDenton86 sounds like other iOS8 trouble than phonegap related - and that's what this fix is for, not anything else.

You are right.. JQM doesn't load as it should, but it is related to the userAgent because changing that value before loading JQM, I see diferences - but still it's not as it supposed to be.
Thanks anyway

I am using cordova with ionic and this is working like a charm .. Thank you!

I just used this fix and it works for me with Cordova 3.4.0. Note that I had to add the javascript after all of the Cordova javascript - including the plugins.


EddyVerbruggen commented Jun 18, 2014

Heads up: iOS 8 beta 2 fixes the userAgent issue, so you no longer require this fix. Yippeeee!

sixman9 commented Dec 16, 2014

Hi, newbie question here but would this trick also affect the way Phonegap/Cordova reports its browser user agent when making external HTTP requests?

If yes, then this is a much simpler way than these suggestions:

change-phonegap-user-agent (@Stackoverflow, for IOS)


change-phonegap-cordova-user-agent-for-ajax (@Stackoverflow, for Android)

Of course, I do realise I could just test it out ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment