5
votes

I'm trying to get my Cordova iPhone app working in iOS 8.1

Working fine in 7, since 8 I'm getting the following error:

Deprecated attempt to access property 'userAgent' on a non-Navigator object.

This is breaking the rendering of the app in page so I need a fix. I've taken a look at the various proposed solutions around the web but none seem to work.

Interestingly the error is coming from the JS retrieved from "https://maps.gstatic.com/maps-api-v3/api/js/17/17/main.js". --- perhaps part of the Google Maps API I'm trying to use?

Any help on the matter would be amazing!

Many thanks

Chris

2

2 Answers

14
votes

Which cordova version are you using?

That should be fixed now in the latest version, but if you don't want to update the project, you can change replaceNavigator function to be like this on the cordova.js file (the whole else is new)

function replaceNavigator(origNavigator) {
        var CordovaNavigator = function() {};
        CordovaNavigator.prototype = origNavigator;
        var newNavigator = new CordovaNavigator();
        // This work-around really only applies to new APIs that are newer than Function.bind.
        // Without it, APIs such as getGamepads() break.
        if (CordovaNavigator.bind) {
            for (var key in origNavigator) {
                if (typeof origNavigator[key] == 'function') {
                    newNavigator[key] = origNavigator[key].bind(origNavigator);
                } else {
                    (function(k) {
                        Object.defineProperty(newNavigator, k, {
                            get: function() {
                                return origNavigator[k];
                            },
                            configurable: true,
                            enumerable: true
                        });
                    })(key);
                }
            }
        }
        return newNavigator;
    }
0
votes

it looks like a known issue in cordova that can be fixed by updating your cordova version (as well as plugins?)

from Cordova Jira

If you want to get the fix simply do the following:

  1. Clone the cordova-js (Version 3.7)
  2. Grunt the git, this will create all the native js files.
  3. Replace the cordova.js in your platform_www folder