我正试图让我的Cordova iPhone应用程序在iOS 8.1 中运行
在7中工作良好,由于8,我得到以下错误:
Deprecated attempt to access property 'userAgent' on a non-Navigator object.
这破坏了应用程序在页面中的呈现,所以我需要修复。我看了一下网络上提出的各种解决方案,但似乎都不起作用。
有趣的是,错误来自从"https://maps.gstatic.com/maps-api-v3/api/js/17/17/main.js"可能是我尝试使用的谷歌地图API的一部分?
这件事上的任何帮助都将是惊人的!
非常感谢
Chris
您使用的是哪种cordova版本?
这在最新版本中应该已经修复,但如果你不想更新项目,你可以在cordova.js文件上将replaceNavigator函数更改为这样(其他都是新的)
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;
}
这看起来像是cordova中的一个已知问题,可以通过更新您的cordova版本(以及插件?)来修复
来自Cordova Jira
如果你想得到修复,只需执行以下操作:
- 克隆cordova js(3.7版)
- Grunt the git,这将创建所有本地js文件
- 替换platform_www文件夹中的cordova.js