【问题标题】:Send push notification to specific user using Parse使用 Parse 向特定用户发送推送通知
【发布时间】:2015-11-09 22:17:08
【问题描述】:

我想使用 PHP 向特定用户发送推送通知。我知道这个问题被问了很多次。但我的问题有点不同。在我的情况下,推送通知是发送给所有用户的,即使我已指定它向特定用户发送推送,

为此,每当用户在其 Android 设备上安装应用程序时,我都会在 Parse.com 的安装表中保存一个唯一 ID。 这是android应用程序中的代码:

Parse.initialize(this, "XXXX", "XXXX");
ParseInstallation installation = ParseInstallation.getCurrentInstallation();
installation.put("device_id", Secure.getString(getContentResolver(), Secure.ANDROID_ID));
installation.saveInBackground();

这很好用。我可以在解析器的安装表中看到 id。

现在,这是我用来向特定设备 ID 发送推送通知的 php 脚本。它确实会发送推送通知,但会发送给所有用户。

require_once('autoload.php');

use Parse\ParseInstallation;
use Parse\ParsePush;
use Parse\ParseClient;

ParseClient::initialize( 'XXXXXX', 'XXXXX', 'XXXXX' );

function sendPush($query){
    $notification = "Test notification!";
    $data = array("alert" => $notification);
    ParsePush::send(array(
        "where" => $query,
        "data" => $data
    ));
}

$query = ParseInstallation::query();
$query->equalTo("device_id", "XXXXXX");
sendPush($query);

【问题讨论】:

  • 如果您尝试通过 Parse Dashboard 发送它是否有效?
  • 是的,通过 Parse Dashboard 可以正常工作。

标签: php android parse-platform


【解决方案1】:

在搜索了很多解决方案后,我查看了他们的 github 问题页面,并在“已关闭问题”部分找到了 similar issue。解决方案是只更新 SDK。因为他们在ParsePush.php 中打错了字。 因此,如果有人遇到此问题,请更新您的 Parse PHP SDK

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多