我正在使用最新版本的 PhoneGap 开发适用于 iOS 和 Android 的 Web 应用程序。
我想在手机状态栏上向用户发送通知,但我不知道该怎么做。
似乎曾经存在过一个 Cordova 插件(StatusBarNotification),但我找到的所有链接都已失效。
如果有人知道向状态栏发送通知的方法,我将不胜感激。
Thanks
Quentin
编辑:我应该更具体:我试图了解如何使用手机上的状态区域(http://developer.android.com/guide/topics/ui/notifiers/notifications.html http://developer.android.com/guide/topics/ui/notifiers/notifications.html),为此我有一个带有按钮的简单 html 文件。我希望在单击按钮时在状态区域上显示通知。 (就像当您收到短信时,您会收到通知)。
<!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)上测试这个应用程序。
编辑:我最终在我的节点服务器上使用了适用于 Android 设备的 Google Cloud Messaging (gcm) 和 Apple Push Notification (apn)。这对于 Android 设备来说效果很好,对于 iPhone 来说有点困难