Last active
December 8, 2018 05:28
-
-
Save EddyVerbruggen/cd02c73162180793513e to your computer and use it in GitHub Desktop.
iOS8 Beta Phonegap fix: manually set the navigator.userAgent
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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"); | |
}); | |
} |
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.
Heads up: iOS 8 beta 2 fixes the userAgent issue, so you no longer require this fix. Yippeeee!
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
I am using cordova with ionic and this is working like a charm .. Thank you!