Instantly share code, notes, and snippets.

Embed
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

This comment has been minimized.

basterbrugge commented Jun 5, 2014

epic!

@wtfaremyinitials

This comment has been minimized.

wtfaremyinitials commented Jun 6, 2014

Thanks!!!

@JcDenton86

This comment has been minimized.

JcDenton86 commented Jun 7, 2014

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

This comment has been minimized.

Owner

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.

@JcDenton86

This comment has been minimized.

JcDenton86 commented Jun 8, 2014

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

This comment has been minimized.

aelshamy commented Jun 10, 2014

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

@dheidebrecht

This comment has been minimized.

dheidebrecht commented Jun 17, 2014

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

This comment has been minimized.

Owner

EddyVerbruggen commented Jun 18, 2014

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

@sixman9

This comment has been minimized.

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