我正在尝试将通知发送到使用php
安装了我的应用的设备,使用'included_segments' => array('All')
时向所有用户成功发送通知
,但是当我尝试使用过滤器时,我收到All included players are not subscribed
响应错误,这是我正在使用的推送通知脚本:
push.php
<?PHP
function sendMessage(){
$content = array(
"en" => 'Testing Message'
);
$fields = array(
'app_id' => <omitted>,
'filters' => array(array("field" => "tag", "key" => "etab", "relation" => "=", "value" => "1")),
'data' => array("foo" => "bar"),
'large_icon' =>"ic_launcher_round.png",
'contents' => $content
);
$fields = json_encode($fields);
print("\nJSON sent:\n");
print($fields);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://onesignal.com/api/v1/notifications");
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json; charset=utf-8',
'Authorization: Basic <omitted>'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
$response = curl_exec($ch);
curl_close($ch);
return $response;
}
$response = sendMessage();
$return["allresponses"] = $response;
$return = json_encode( $return);
print("\n\nJSON received:\n");
print($return);
print("\n");
?>
输出
JSON sent: {"app_id":<omitted>,"filters":[{"field":"tag","key":"etab","relation":"=","value":"1"}],"data":{"foo":"bar"},"large_icon":"ic_launcher_round.png","contents":{"en":"Testing Message"}} JSON received: {"allresponses":"{\"id\":\"\",\"recipients\":0,\"errors\":[\"All included players are not subscribed\"]}"}
我检查了Android应用程序中的可用标签,并且该标签已成功实现并且可以正常使用。
答案 0 :(得分:0)
"All included players are not subscribed"
消息可能表示以下任何内容。
app_id
。