简体   繁体   English

解析推送不只提供云代码

[英]Parse Push's not delivered cloud code only

I'm running parse-server on ubuntu and can't seem to get push notifications working when sent in cloud code. 我在ubuntu上运行parse-server,当以云代码发送时似乎无法使推送通知正常工作。

Push's work when using a REST api call (passing master key) but don't work when cloud code calls them. 在使用REST api调用(传递主密钥)时,Push可以工作,但是在云代码调用它们时,Push不起作用。

What's interesting is that the cloud code Parse.Push() method returns a success and thus no error message. 有趣的是,云代码Parse.Push()方法返回成功,因此没有错误消息。

My hypothesis is that this is a configuration problem, and the Parse.Push() method is referencing somethign I have incorrectly configured on the server. 我的假设是这是一个配置问题,并且Parse.Push()方法引用的是我在服务器上错误配置的东西。

here is my cloud function. 这是我的云功能。 This call works when sent via REST. 通过REST发送时,此调用有效。 and the success callback in cloud is always called. 并且总是调用云中的成功回调。

Parse.Push.send(
  {
   // where: pushQueryClient,
    channels: ["user_tkP7gurGzc"],
    data:
    {
        alert: pushTextClient
    }
  },
  {
     success:function(){
        console.log("push sent");
        },
      error: function(error){
        console.log("push failed");
        console.dir(error);
       },

   useMasterKey: true});

i think you have an issue with the useMasterKey parameter. 我认为您对useMasterKey参数有问题。 Please try to use this code in order to send the push notification: 请尝试使用以下代码来发送推送通知:

  Parse.Push.send({ where: whereQuery, data: { alert: { title: request.params.title, body: request.params.body }, type: request.params.type, sound: 'default' } }, { useMasterKey: true }).then(function() { response.success(); }, function(error) { response.error("Push failed " + error); }); 

In this code i use Promises which is the best practice and also wrap useMasterKey in a separate object 在此代码中,我使用Promises(这是最佳实践),还将useMasterKey包装在单独的对象中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM