só por curiosidade, qual serviço de push esta usando ? nacional ?
Estou usando gcm do google, configurei no console Developers e estou utilizando esse código aqui:
<?php
class GCMPushMessage {
var $url = 'https://android.googleapis.com/gcm/send';
var $serverApiKey = "";
var $devices = array();
function GCMPushMessage($apiKeyIn){
$this->serverApiKey = $apiKeyIn;
}
function setDevices($deviceIds){
if(is_array($deviceIds)){
$this->devices = $deviceIds;
} else {
$this->devices = array($deviceIds);
}
}
function send($message, $data = false){
if(!is_array($this->devices) || count($this->devices) == 0){
$this->error("No devices set");
}
if(strlen($this->serverApiKey) < 8 ){
$this->error("Server API Key not set");
}
$fields = array(
'registration_ids' => $this->devices,
'data' => array( "message" => $message ),
);
if(is_array($data)){
foreach ($data as $key => $value) {
$fields['data'][$key] = $value;
}
}
$headers = array(
'Authorization: key=' . $this->serverApiKey,
'Content-Type: application/json'
);
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, $this->url );
curl_setopt( $ch, CURLOPT_POST, true );
curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch, CURLOPT_POSTFIELDS, json_encode( $fields ) );
curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
function error($msg){
echo "Android send notification failed with error:";
echo "\t" . $msg;
exit(1);
}
}
if(isset($_POST) && !empty($_POST)){
$apiKey = $_POST["apiKey"];
$devicesToken = explode(",",$_POST["devices"]);
$gcpm = new GCMPushMessage($apiKey);
$gcpm->setDevices($devicesToken);
$title = $_POST["title"];
$message = $_POST["message"];//"Seja bem vindo, José!"; //message o send
$response = $gcpm->send($message, array('title' => $title)); //title of the message
echo $response;
}
No teste sem ser pelo scriptcase funciona 100%, mas quando gero o app blank não funciona, já setei os valores no código e sempre da erro.
O erro é esse aqui: Fatal error: Class declarations may not be nested in C:\Program Files (x86)\NetMake\v81\wwwroot\scriptcase\app\XXXXXXl\push\index.php on line 1023