【问题标题】:parse - can't send push notifications from device解析 - 无法从设备发送推送通知
【发布时间】:2014-11-11 03:03:46
【问题描述】:

您好,我正在尝试从一台设备向另一台设备发送推送通知。

这是我的代码:

public void onClick(View v) {
            // TODO Auto-generated method stub
            ParseQuery pushQuery = ParseInstallation.getQuery();
            pushQuery.whereEqualTo("gender", "male");

            ParsePush pushMsg = new ParsePush();
            pushMsg.setQuery(pushQuery);
            pushMsg.setMessage("Hey Male!");
            pushMsg.sendInBackground(new SendCallback() {

                @Override
                public void done(ParseException e) {
                    // TODO Auto-generated method stub
                    if(e!=null)
                        e.printStackTrace();
                    else
                        Log.i("Send push", "Success");
                }
            });
        }

问题是当我尝试发送通知时,日志显示“成功”,但我的设备中没有收到任何信息。 当我将相同的参数放在仪表板上时,它可以完美运行。 请就这个问题指导我。

【问题讨论】:

  • 您的客户端推送启用了吗?
  • 启用是什么意思?当我从仪表板发送时,我确实在手机上收到了通知。只有当我尝试从设备本身发送时它才起作用。
  • 编辑:我也尝试通过云代码发送推送通知。我从回调中收到“成功”响应,但没有收到任何通知...

标签: android notifications parse-platform push send


【解决方案1】:

您的第二台设备未注册或未登录,或者您没有为他设置“性别”=“男性”这里是 如何注册here

如何登录here

登录后如何设置"gender"="male":

ParseUser u= ParseUser.getCurrentUser() ;
        u.put("location", point);
 u.saveInBackground();

还设置标题推送

    ParsePush pushMsg = new ParsePush();
            pushMsg.setQuery(pushQuery);
  pushMsg.settitle("title");
            pushMsg.setMessage("Hey Male!");
pushMsg.sendInBackground();

【讨论】:

  • 两个设备都已注册并登录。查询是根据我提供的信息。 ParsePush 中没有名为“settitle”的方法。
  • 您是否“允许从设备发送”通知?在 Parse.com 网站上的项目设置中?
  • 打开你的项目,点击“设置”-在左侧“常规”下点击“推送”-在此设置中打开“启用客户端推送”
猜你喜欢
  • 1970-01-01
  • 2015-11-21
  • 1970-01-01
  • 2017-12-07
  • 1970-01-01
  • 2019-05-12
  • 2020-12-24
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多