2
我正在嘗試使用OneSignal設置基於位置的推送通知,但我沒有收到通知。我收到錯誤All included players are not subscribed
。我看不出有什麼問題,有什麼想法?爲什麼我收到消息「所有包含的玩家沒有訂閱」?
在「所有用戶」的OneSignal列表中,沒有收到通知的用戶使用期望的經緯度座標和用戶訂閱的「位置點」。我收到了沒有位置的通知,因此發送和接收通知的過程都有效。
我已經添加了此行我的AndroidManifest.xml文件:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
我也有這個線在我的.run
功能:
window.plugins.OneSignal.promptLocation();
我的PHP發送請求到OneSignal:
$content = $_GET['content'];
$lat = $_GET['lat'];
$long = $_GET['long'];
$radius = $_GET['radius'];
$response = sendMessage($content, $lat, $long, $radius);
function sendMessage($message, $lat, $long, $radius){
$content = array(
"en" => $message
);
$fields = array(
'app_id' => "aaaaaa-eeee-yyyyy-xxxx-zzzz",
'filters' => array(array("field" => "location", "radius" => $radius, "lat" => $lat, "long" => $long)),
//'filters' => array(array("field" => "location", "radius" => "1000", "lat" => "55.819329", "long" => "-4.1696119")),
'included_segments' => array('All'),
'data' => array("foo" => "bar"),
'contents' => $content
);
$fields = json_encode($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 FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'));
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;
}
要求:
{content: "test", lat: "55.8653169", long: "-4.1696119", radius: "1000"}
響應:
{allresponses: "{"id":"","recipients":0,"errors":["All included players are not subscribed"]}"}