[英]status bar notification in web application
I have a responsive web application and want to show notifications in the status bar of the mobile when the app is running in the mobile browser. 我有一个响应式Web应用程序,并且当该应用程序在移动浏览器中运行时,希望在移动设备的状态栏中显示通知。 After googling the best I can find is this : status-bar-notification 谷歌搜索后,我能找到的最好的是: status-bar-notification
I am unable to understand how this would help to show the notification. 我无法理解这将如何帮助显示通知。 Similar to the question in the aforementioned link I want to show notification on click. 与上述链接中的问题类似,我想在点击时显示通知。
<!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>
Is there any way to achieve this ? 有什么办法可以做到这一点?
There are two types of notifications: 通知有两种类型:
– Local notification, which you can generate IN your app. –本地通知,您可以在应用程序中生成本地通知。
– Push notifications, which are provided by Apple, Google, … or some notification providers. –推送通知,由Apple,Google或某些通知提供者提供。
For both you need a plugin, have a look at the cordova plugin site . 对于这两者,您都需要一个插件,请查看cordova插件站点 。
If you use local notifications, then the plugin generates the message in the status bar, not your JS! 如果您使用本地通知,那么插件会在状态栏中生成消息,而不是JS! But you give the plugin the message, an icon and a badge number. 但是,您要给插件提供消息,图标和徽章编号。
All of the notification handling has to be inside your app. 所有通知处理都必须在您的应用程序内部。 That means for example: You have to remove notifications, if the are no more used, the count of badge numbers, etc.. 例如,这意味着:您必须删除通知,如果不再使用通知,则必须删除徽章编号等。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.