12

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"]}"}
user1532669
  • 2,288
  • 4
  • 36
  • 72

3 Answers3

20

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.

jkasten
  • 3,899
  • 3
  • 32
  • 51
3

I had the same issue, I realised that I wasn't setting the platforms to true; I'm using the Ruby SDK, so i needed to make sure I set the following to true.

notifcation.is_ios = true

notification.is_android = true

Aiman Farhan
  • 111
  • 1
  • 2
0

We had the same problem with a couple of apps, which was weird because the first app worked. It turned out that in our eagerness to see things work, we forgot to upload the OneSignal SDK files to the root directory of the website. Make sure that the following files are uploaded to the root directory of your website:

  • OneSignalSDKUpdaterWorker.js
  • manifest.json
  • OneSignalSDKWorker.js

You can download the SDK from here.

itoctopus
  • 4,133
  • 4
  • 32
  • 44