使用PhoneGap / Cordova的Web应用程序的状态栏通知 [英] Status bar notification for web app with PhoneGap / Cordova

查看:120
本文介绍了使用PhoneGap / Cordova的Web应用程序的状态栏通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用最新版本的PhoneGap开发适用于iOS和Android的网络应用程序。

I am developping a web app for iOS and Android, using the last version of PhoneGap.

我想在用户的手机状态栏上发送通知,我不知道该怎么做。
看来有一个Cordova插件(StatusBarNotification),一旦存在,但是我发现的所有链接都已经死了。

I want to send Notifications to the users on their phone's status bar, and I cannot figure out how to do that. It seems that there was a Cordova plugin (StatusBarNotification) that once existed, but all the links I find are dead.

如果有人知道发送

感谢

Quentin

编辑:我应该更具体:我想了解如何使用手机上的状态区域( http://developer.android.com/guide/topics/ui/notifiers/notifications.html ),为此,我有一个简单的html文件一个按钮。我希望在单击按钮时在状态区域上显示通知。 (例如当您收到短信时,您有通知)。

EDIT : I should have been more specific : I am trying to understand how to use the status area on phones (http://developer.android.com/guide/topics/ui/notifiers/notifications.html), and for that I have a simple html file with a button. I want a notification to appear on the status area when I click the button. (like when you receive a text message, you have a 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 notif to appear in the status bar
            });
        </script>
    </body>
</html>

我在Nexus 4上使用Android 4.4.2测试此应用程式。

I am testing this app on my Nexus 4, with Android 4.4.2.

编辑:我最终在我的节点服务器上使用Android设备的Google云消息传递(gcm)和Apple Push Notification(apn)。这对于Android设备很好,对于iphones有点难。

EDIT : I ended up using Google Cloud Messaging (gcm) for android devices and Apple Push Notification (apn) on my node server. This works pretty well with android devices, a bit harder for iphones

推荐答案

也许它已经晚了,这将使您的furhter工作与通知在PhoneGap。要在最新版本的PhoneGap(v3.x)中使用 StatusBarNotifications , ,您需要一个适当的插件工作。应使用安装Cordova CLI

Perhaps its already to late for the answer, but I think this would make sence for your furhter work with notifications in PhoneGap. For using StatusBarNotifications in latest versions of PhoneGap (v3.x), you need to a proper Plugin that will work. This should be installed with Cordova CLI.

对于旧版本的PhoneGap( v2.9 及更低版本),您仍然可以使用 GitHub

For the older versions of PhoneGap (v2.9 and below) you still can use DEPRECATED version of StatusBarNotifications from GitHub.

顺便说一句,使用旧版本对于没有经验的开发者来说不太头痛:)

By the way, using of older version is less headache for not experienced developers :)

希望这会帮助你。

这篇关于使用PhoneGap / Cordova的Web应用程序的状态栏通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆