我有一个非常奇怪的错误,即在用户与操作系统本身交互之前,设备就绪事件不会在 iOS 设备中触发,即按下前按钮,通过向下拖动显示通知中心或向上拖动进入设备设置。
一旦用户开始拖动 iOS 通知中心,就会触发 deviceready。
像这样简单的事情是行不通的:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width" />
<meta http-equiv="Content-Security-Policy" content="default-src 'self' data:* gap:* tel:* 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'" />
<title></title>
<!-- cordova script (this will be a 404 during development) -->
<script src="cordova.js"></script>
</head>
<body>
<div id="log"></div>
<script type="text/javascript">
var log = document.getElementById("log");
if(window.cordova){
log.innerHTML = "with cordova";
document.addEventListener("deviceready", function onDeviceReady(){
log.innerHTML = "deviceready";
}, false);
}else{
log.innerHTML = "with browser";
}
</script>
</body>
</html>