我正在尝试使用OneSignal设置基于位置的推送通知,但我没有收到通知.我收到错误所有包含的玩家都没有订阅.我不知道问题是什么,有什么想法吗? 在“所有用户”的OneSignal列表上,未接收
在“所有用户”的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"]}"}“所有包含的玩家未订阅”消息可能意味着以下任何一种情况.
>确保您已设置正确的app_id.
>您没有订阅用户.
>您尚未在OneSignal仪表板的“应用程序设置”页面上为您的设备设置平台.
>过滤器中没有用户.
在您的情况下,位置可能超过1000米.尝试增加半径并确认您在OneSignal仪表板上的“所有用户”页面上看到“位置点”.