导航器通知警报在Cordova不起作用
navigator notification alert not working in Cordova
我正试图用Cordova打印警报,只有当我用Ripple Chrome扩展程序模拟我的应用程序时,它才能工作。
在我的三星Galaxy S3中,当我点击按钮时,什么都不会发生。
我使用的是Cordova 3.6.3-0.2.13。我在我的项目中添加了以下插件:org.apache.cordova.dialogs和org.apache.cordova.vibration。(如果我键入"cordova plugins ls",它们都会出现)
<html>
<head>
<script type="text/javascript" charset="utf-8">
function getInfo() {
navigator.notification.alert(
'Model: ' + device.model, // message
null, // callback
'Info', // title
'Ok' // buttonName
);
}
</script>
<meta charset="utf-8" />
<meta name="format-detection" content="telephone=no" />
<meta name="msapplication-tap-highlight" content="no" />
<!-- WARNING: for iOS 7, remove the width=device-width and height=device-height attributes. See https://issues.apache.org/jira/browse/CB-4323 -->
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
<link rel="stylesheet" type="text/css" href="css/index.css" />
<title>Hello World</title>
</head>
<body>
<div class="app">
<h1>Apache Cordova</h1>
<div id="deviceready" class="blink">
<p class="event listening">Connecting to Device</p>
<p class="event received">Device is Ready</p>
</div>
<button id="gobutton" type="button" onclick="getInfo()">CLICK ME</button>
</div>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="js/index.js"></script>
</body>
</html>
而我的index.js是:
var app = {
// Application Constructor
initialize: function() {
this.bindEvents();
},
// Bind Event Listeners
//
// Bind any events that are required on startup. Common events are:
// 'load', 'deviceready', 'offline', and 'online'.
bindEvents: function() {
document.addEventListener('deviceready', this.onDeviceReady, false);
},
// deviceready Event Handler
//
// The scope of 'this' is the event. In order to call the 'receivedEvent'
// function, we must explicitly call 'app.receivedEvent(...);'
onDeviceReady: function() {
app.receivedEvent('deviceready');
},
// Update DOM on a Received Event
receivedEvent: function(id) {
var parentElement = document.getElementById(id);
var listeningElement = parentElement.querySelector('.listening');
var receivedElement = parentElement.querySelector('.received');
listeningElement.setAttribute('style', 'display:none;');
receivedElement.setAttribute('style', 'display:block;');
console.log('Received Event: ' + id);
}
};
app.initialize();
你能帮我吗?提前感谢
Dawson的评论应该有效。
正如您在Cordova文档页面上看到的:http://docs.phonegap.com/en/2.2.0/cordova_notification_notification.md.html#notification.alert
代码:
navigator.notification.alert
是在加载cordova库之后。
相关文章:
- Cordova插件在使用Framework7时不起作用
- Cordova/Phonegap OnClick 不起作用
- 用户定义的函数在 Angular Cordova 中不起作用
- Cordova电子邮件作曲家在Android上不起作用
- Cordova iframe在iOS Safari中工作,但在Android中不起作用
- IOS Cordova/Phonegap 离线视频源标签不起作用
- Ionic + Cordova InappBrowser - 输入类型=文件不起作用
- 升级到 cordova 3.1.0 后,推送插件不起作用
- Phonegap/Cordova facebook 登录在已经连接时不起作用
- Cordova应用程序到WP8窗口.位置不起作用Windows Phone
- Cordova iOS Javascript不起作用
- PhoneGap/Cordova CanvasCamera 插件不起作用
- 带有 Angular JS 的 JSON 不起作用(Ionic & Cordova)
- Cordova自定义URL方案插件在iOS模拟器中不起作用
- 导航器通知警报在Cordova不起作用
- PhoneGap/Cordova没有监听401,将http响应代码修改为200不起作用
- Cordova:使用javascript api登录facebook不起作用
- Cordova-扫描二维码并打开链接..不起作用
- 下载进度事件在使用 cordova 插件文件传输的 ios 中不起作用
- cordova插件失眠不起作用