Phonegap / Cordova not working in ios8

12,447

Solution 1

You can fix this with a bit of Javascript in your index.html (or install iOS 8 beta 2, which seems to have fixed the issue): https://gist.github.com/EddyVerbruggen/cd02c73162180793513e#file-ios8-beta-phonegap-fix

// temp fix for iOS8 beta, add it after the reference to cordova.js
// You don't actually require it for ios 8 beta 5
if (navigator.userAgent === undefined) {
  navigator.__defineGetter__('userAgent', function() {
    return("Mozilla/5.0 (iPhone; CPU iPhone OS 8_0 like Mac OS X) AppleWebKit");
  });
}

Solution 2

In early iOS 8 Betas, Cordova/Phonegap apps were broken due to a user agent bug, but according to the iOS 8 Beta release notes (WebKit section) this bug was officially fixed in iOS 8 Beta 3. (It was actually already fixed in iOS 8 Beta 2.)

Good to see that Apple has tested Cordova/Phonegap apps and fixed this issue. A bit disappointing that the bug existed in the first place, but early betas always have lots of issues.

Solution 3

A plain cordova sample app (e.g. "cordova create test") will load fine.

If you add any cordova plugins you will encounter problems in "iOSExec()", see "platform_www/cordova.js":

bridgeMode = navigator.userAgent.indexOf(' 5_') == -1 ? jsToNativeModes.IFRAME_NAV: jsToNativeModes.XHR_NO_PAYLOAD;

Change that to:

bridgeMode = jsToNativeModes.IFRAME_NAV;

and you can use plugins again. This will break backwards compatibility with iOS 5, but i doubt you will find anybody running iOS 5 and cordova today...

If you are using fastclick.js or backbone.js you will have to make some small modifications, too. Just follow the error messages in Safari's webinspector.

Solution 4

Update XCode to Beta 2 and it's working without any fix (tested with cordova 3.5.0).

You need to download the new version of XCode on the iOS Dev Center since autoupdate is not yet available for beta..

Share:
12,447
user3660133
Author by

user3660133

Updated on June 04, 2022

Comments

  • user3660133
    user3660133 almost 2 years

    I played around with the iOS 8 beta and noticed that Cordova/Phonegap is pretty much broken.

    For me it is mainly the InAppBrowser that now doesn't show up.

    what are your experiences? Do you have a fix or an idea for a solution?

    Thanks.