gpt4 book ai didi

javascript - 使用 PhoneGap/Cordova 的 Web 应用程序的状态栏通知

转载 作者:行者123 更新时间:2023-11-29 15:39:17 26 4
gpt4 key购买 nike

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

我想在用户手机的状态栏上向用户发送通知,但我不知道该怎么做。似乎曾经有一个Cordova插件(StatusBarNotification)存在,但我找到的所有链接都死了。

如果有人知道如何将通知发送到状态栏,我将不胜感激。

谢谢

昆汀

编辑:我应该更具体一些:我正在尝试了解如何使用手机上的状态区 (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>

我正在使用 Android 4.4.2 的 Nexus 4 上测试此应用。

编辑:我最终在我的节点服务器上为 Android 设备使用 Google Cloud Messaging (gcm),并使用 Apple Push Notification (apn)。这在 Android 设备上工作得很好,对于 iPhone 有点困难

最佳答案

也许现在回答已经太晚了,但我认为这对您在 PhoneGap 中进一步处理通知很有意义。使用StatusBarNotifications在最新版本的 PhoneGap (v3.x) 中,您需要正确的 Plugin那可行。这应该与 Cordova CLI 一起安装.

对于旧版本的 PhoneGap(v2.9 及以下版本),您仍然可以使用 GitHub 中已弃用的 StatusBarNotifications 版本.

顺便说一句,对于没有经验的开发人员来说,使用旧版本并不那么令人头疼:)

希望对您有所帮助。

关于javascript - 使用 PhoneGap/Cordova 的 Web 应用程序的状态栏通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22398975/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com