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");
});
}
@basterbrugge

epic!

@wtfaremyinitials

Thanks!!!

@JcDenton86

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
Owner

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

@JcDenton86

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

@aelshamy

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

@dheidebrecht

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
Owner

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

@sixman9
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