【问题标题】:How to setup Meteor Raix Push Package for Push Notifications如何为推送通知设置 Meteor Raix 推送包
【发布时间】:2023-03-03 21:12:01
【问题描述】:

我正在尝试将这个 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 上,我得到了一个令牌,但在这两种情况下都没有发送推送通知。

如果您对未发送推送通知的原因有任何想法,请告诉我。谢谢

【问题讨论】:

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


    【解决方案1】:

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

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

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

    ``` 查询:{

    userId: 'xfaafsdlfhjeorhj239n'

    }
    

    ```

    如果你没有使用流星的不安全包添加

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

    【讨论】:

      猜你喜欢
      • 2023-03-15
      • 2021-09-20
      • 2013-07-16
      • 1970-01-01
      • 1970-01-01
      • 2015-03-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多