Skip to content

Instantly share code, notes, and snippets.

@EddyVerbruggen
Last active December 8, 2018 05:28
Show Gist options
  • Star 16 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save EddyVerbruggen/cd02c73162180793513e to your computer and use it in GitHub Desktop.
Save EddyVerbruggen/cd02c73162180793513e to your computer and use it in GitHub Desktop.
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
Copy link

epic!

@wtfaremyinitials
Copy link

Thanks!!!

@JcDenton86
Copy link

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
Copy link
Author

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

@JcDenton86
Copy link

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
Copy link

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

@dheidebrecht
Copy link

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
Copy link
Author

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

@sixman9
Copy link

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