Parse.com 向多种设备类型发送推送通知,即Android和iOS无法正常工作


Parse.com sending push notification to multiple device types i.e Android and iOS not working

我使用以下代码使用 REST API 从我的 PHP 表单发送 parse.com 推送通知。

$APPLICATION_ID = 'Applicatio_id_here';
    $REST_API_KEY = 'Rest_api_key_here';

    $data = [
        'where' => ['channels' => ''],
        'expiry' => time() + 1000,
        'data' => [
            'alert' => $notification,
        ],
    ];
    $_data = json_encode($data);
    $headers = [
        'X-Parse-Application-Id: ' . $APPLICATION_ID,
        'X-Parse-REST-API-Key: ' . $REST_API_KEY,
        'Content-Type: application/json',
        'Content-Length: ' . strlen($_data),
    ];
    $curl = curl_init($url);
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $_data);
    curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_exec($curl);

我的 parse.com 帐户同时设置了Android和iOS推送通知。并且我能够在Android设备上成功获得通知。但问题出在iPhone上。我在iPhone设备上没有收到任何通知。

但是,如果我从 parse.com 管理员发送通知(发送推送),iPhone设备已成功接收通知。

还有一件事要提一下,parse.com 管理员中,我可以看到 iOS 设备的频道 = ["global"],但 Android 设备的 ["] 空白。所以我认为我的PHP代码中可能存在一些问题。

如果无法使用此代码发送相同的消息,请帮助我使用一些工作代码。我需要这个,因为我的两个设备的应用程序都已经在线。

尝试将"$data"更改为此值:

$data = [ 'where' => ['channels' => 'global'] OR  ['channels' => ''], 'expiry' => time() 

另一种选择:

$data = ['where' => 'channels' => 'global' OR  'channels' => '', 'expiry' => time()