Cordoba is an outdated attempt to access a userAgent resource on an object other than Navigator

I am trying to get an iPhone application from Cordoba running on iOS 8.1

Works fine in 7, with 8 I get the following error:

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

This violates the rendering of the application on the page, so I need to fix it. I reviewed various proposed solutions on the Internet, but none of them work.

Interestingly, the error comes from JS obtained from " https://maps.gstatic.com/maps-api-v3/api/js/17/17/main.js ". --- Perhaps the part of the Google Maps API I'm trying to use?

Any help on this would be awesome!

Many thanks

Chris

+5
source share
2 answers

What version of cordova are you using?

This should be fixed now in the latest version, but if you do not want to update the project, you can change the replaceNavigator function so that it is in the cordova.js file (everything 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; } 
+14
source

this seems like a known issue in cordova that can be fixed by updating the version of cordova (as well as plugins?)

from Cordoba Gira

If you want a fix, just follow these steps:

  • Clone the cordova-js (version 3.7)
  • Grunt git, this will create all native js files.
  • Replace cordova.js in the platform_www folder
0
source

Source: https://habr.com/ru/post/1205868/


All Articles