Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why am I receiving the message "All included players are not subscribed"?

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"]}"}
like image 781
user1532669 Avatar asked Nov 19 '16 14:11

user1532669


1 Answers

The "All included players are not subscribed" message could mean any of the following.

  1. Ensure you have set the correct app_id.
  2. You have no subscribed users.
  3. You haven't setup a platform for your devices on the App Settings page on OneSignal's dashboard.
  4. There are no users in the filter.

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.

like image 165
jkasten Avatar answered Nov 09 '22 14:11

jkasten