我有一个响应式Web应用程序,并且当该应用程序在移动浏览器中运行时,希望在移动设备的状态栏中显示通知。
谷歌搜索后,我能找到的最好的是:status-bar-notification
我无法理解这将如何帮助显示通知。
与上述链接中的问题类似,我想在点击时显示通知。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="format-detection" content="telephone=no" />
<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>
<input type="button" value="Notiiiiiiif" id="btNotif"/>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="js/index.js"></script>
<script type="text/javascript">
app.initialize();
btNotif = document.getElementById('btNotif');
btNotif.addEventListener('click', function(){
//There I want a notification to appear in the mobile status bar
});
</script>
</body>
</html>
有什么办法可以做到这一点?
最佳答案
通知有两种类型:
–本地通知,您可以在应用程序中生成本地通知。
–推送通知,由Apple,Google或某些通知提供者提供。
对于两者,您都需要一个插件,请查看cordova plugin site。
如果您使用本地通知,那么插件会在状态栏中生成消息,而不是JS!但是,您要给插件提供消息,图标和徽章编号。
所有通知处理都必须在您的应用程序内部。例如,这意味着:您必须删除通知,如果不再使用通知,则必须删除徽章编号等。