2016-11-19 69 views
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"]}"} 

回答

4

"All included players are not subscribed"消息可能意味着以下任一。

  1. 您沒有訂閱用戶。
  2. 您尚未在OneSignal儀表板的「應用程序設置」頁面上爲您的設備設置平臺。
  3. 篩選器中沒有用戶。

就你而言,位置可能超過1000米。嘗試增加半徑並確認您在OneSignal儀表板的「所有用戶」頁面上看到「位置點」。

相關問題