I'm trying to setup location based push notifications using OneSignal and I'm not receiving notifications. I am getting the error All included players are not subscribed
. I don't see what the problem is, any ideas?
On the OneSignal list of "All Users" the user that isn't receiving the notification has the "Location Point" set with the expected lat and long coords and the user is subscribed. I got notifications to send without the location so the process of sending and receiving the notification works.
I've added this line to my AndroidManifest.xml file:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
I also have this line in my .run
function:
window.plugins.OneSignal.promptLocation();
My php that sends the request to 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;
}
Request:
{content: "test", lat: "55.8653169", long: "-4.1696119", radius: "1000"}
Response:
{allresponses: "{"id":"","recipients":0,"errors":["All included players are not subscribed"]}"}
The "All included players are not subscribed"
message could mean any of the following.
app_id
.In your case the location is probably more than 1,000 meters away. Try increasing the radius and confirm that you see a "Location Point" on the All Users page on the OneSignal dashboard.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With