如何设置推送通知的Meteor Raix推送包

时间:2014-12-28 23:52:50

标签: cordova meteor push-notification phonegap-plugins google-cloud-messaging

我正在尝试使用此Push Meteor软件包进行Android和Chrome推送通知。我按照basic instructions并将GCM凭据添加到根目录中的config.push.json文件。

我尝试使用以下命令向浏览器,Android模拟器和Android手机发送推送通知。

  Push.send({
    from: 'Test',
    title: 'Hello',
    text: 'World',
    count: 12,
    query: {
      userId: 'xxxxxxxxxxxx'
    }
  });

当我在浏览器控制台中输入命令时,出现以下错误:

 Uncaught TypeError: undefined is not a function
 notifications.js:40

这似乎是因为没有登录用户。

在Meteor Shell上,我收到了一个令牌,但两种情况都没有发送推送通知。

如果您有任何想法没有发送推送通知,请告诉我。感谢

1 个答案:

答案 0 :(得分:1)

您好我正在向Android手机发送推送通知...尝试向所有人发送推送通知,这意味着省略userId

Push.send({ from: 'Test', title: 'Hello', text: 'World', count: 12, query: { } });

之后,您可以登录您的应用并尝试仅向登录用户发送通知。您必须从mongodb复制用户ID并将其放入查询中,例如

``` 查询:{

userId:' xfaafsdlfhjeorhj239n'

}

```

如果您没有使用meteor的不安全包,请添加

Push.allow({ send: function(userId, notification) { return true; // Allow all users to send } });