我使用phonegap、cordova 和onsen UI 来构建应用程序(仅JS、HTML5)。我们使用 Pusher.com 进行推送通知。 如何使用我的推送服务器向我的应用程序添加推送通知?现有插件使用 GCM、Amazon 或其他推送服务。 什么可以是好的? - 我在我的应用程序中收到推送事件
var pusher = new Pusher('MY_SECRET', {
encrypted: false
});
var channel = pusher.subscribe('my_channel');
channel.bind('new_message', function(data) {
//show message in status bar and set app icon badge to 1
});
只有我需要的是设置应用程序图标徽章并在状态栏中显示消息。
是否有任何解决方案可以在没有内置推送服务的插件的情况下实现此目的?谢谢。
最佳答案
正如您所说:现有推送服务有一些插件可以接收通知,然后在状态栏中提出它。所以这取决于您发送的方式。
这意味着发出通知是 Android 原生的事情。
但是,如果您找不到适合您需求的插件,您可以提出本地通知,例如 with this plugin
示例:
cordova.plugins.notification.local.schedule({
id: 1,
title: "Production Jour fixe",
text: "Duration 1h",
firstAt: monday_9_am,
every: "week",
sound: "file://sounds/reminder.mp3",
icon: "http://icons.com/?cal_id=1",
data: { meetingId:"123#fg8" }
});
cordova.plugins.notification.local.on("click", function (notification) {
joinMeeting(notification.data.meetingId);
});
关于javascript - Phonegap 状态栏通知、Android、iOS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33823549/