简体   繁体   English

如何使用android phonegap在状态栏中显示通知数

[英]how to show the number of notification in the status bar using android phonegap

I am doing a project in android phonegap.Here I want to show the number of notification in the status bar.I have implemented status bar notification using the link Status Bar Notification . 我在android phonegap中做一个项目。在这里我想在状态栏中显示通知数量。我已经使用状态栏通知链接实现了状态栏通知 The code i have changed for showing notification is showing below. 我为显示通知而更改的代码如下所示。

<!DOCTYPE HTML>
<html>
<head>
<title>Cordova</title>

<script type="text/javascript" charset="utf-8" src="cordova-2.0.0.js"></script>
<script type="text/javascript" charset="utf-8" src="jquery-1.7.2.min.js"></script>
<script type="text/javascript" charset="utf-8" src="statusbarnotification.js"></script>

<script type="text/javascript">

var count = 0;

function show_notify(){
    count = count+1 ;
    //alert(count);
    var title = "message";
    var alerts = "You have "+count+ " message";
    window.plugins.statusBarNotification.notify(title, alerts);
}

</script>

</head>
<body>
<a href="#" onclick='show_notify()'>Click!</a>
</body>
</html>

Here each call to function show_notify() increment the value of count and shows the number of notification in the format " You have [1 or 2 or 3...] message ".Here my question is how can i set the value of varibale count to zero after clearing notification in the status bar and where should i change the code to redirect to particular page when clicking notification. 在这里,每次对函数show_notify()的调用都会增加count的值,并以“ 您有[1或2或3 ...]消息 ”的格式显示通知的数量。这里我的问题是如何设置varibale的值清除状态栏中的通知后计数为零,单击通知时我应该在哪里更改代码以重定向到特定页面。

You should have a page where all the notifications are. 您应该有一个页面,其中包含所有通知。 You can reset or decrement the count variable when an notification is read. 您可以在读取通知时重置或减少计数变量。 Or when the notifications page is opened. 或在打开通知页面时。

I'm building an app with JQ-mobi which I really recommend. 我正在用JQ-mobi构建一个我真的推荐的应用程序。 They offer an data attribute 'data-load'. 它们提供了数据属性“数据加载”。 This is when you can run your methods for resetting the notifications. 这是您可以运行用于重置通知的方法的时候。

http://www.jqmobi.com/index.php http://www.jqmobi.com/index.php

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM