有没有办法从服务器清除/设置本地通知?

时间:2015-09-08 04:53:00

标签: cordova meteor notifications

我正在使用meteor.js和local notifications。我可以使用像

这样的东西
cordova.plugins.notification.local.cancel([1, 2], function () {
    // Notifications were cancelled
}, scope);

清除来自移动设备的本地通知,但如果我想从其他设备/计算机上执行此操作,有没有办法?或者我需要使用推送通知吗?

1 个答案:

答案 0 :(得分:0)

我没有使用该软件包,但应该可以这样做:

Notifications = new Mongo.Collection("notifications");

if (Meteor.isClient) {
  Tracker.autorun(function() {
    var messages = Notifications.find({}).fetch();  // trigger autorun on change to collection
    console.log('cancel notification');
    cordova.plugins.notification.local.cancel([1, 2], function() {
      // Notifications were cancelled
    }, scope);
  });
}

if (Meteor.isServer) {
  Meteor.methods({
    cancelNotification: function() {
      Notifications.insert({message: 'cancel Notification'});
    },

  });
}

一个客户端中的Meteor.call('cancelNotification')将触发所有连接的客户端中的自动运行。使用更多代码(过滤发布逻辑),您可以定位特定客户端和/或特定通知。