i developed firebase web app server. sending notifications , seems okay in android app no notifications received. if send notification firebase console comes android app. want send web app.
here php code web app:
public function sendmessage($data,$target=null){ //fcm api url $url = 'https://fcm.googleapis.com/fcm/send'; //api_key available in firebase console -> project settings -> cloud messaging -> server key $server_key = 's6gzacuhibs6gzacaizasyjtkqlzl3fcuhibuhibs6gza8a'; //$fields = array(); //$fields['data'] = $data; if(is_array($target)){ $fields['registration_ids'] = $target; } $fields = array( 'notification' => array('title' => 'working good', 'body' => 'that want'), 'data' => array('message' => "melaapa") ); //header content_type api key $headers = array( 'content-type:application/json', 'authorization:key='.$server_key ); $ch = curl_init(); curl_setopt($ch, curlopt_url, $url); curl_setopt($ch, curlopt_post, true); curl_setopt($ch, curlopt_httpheader, $headers); curl_setopt($ch, curlopt_returntransfer, true); curl_setopt($ch, curlopt_ssl_verifyhost, 0); curl_setopt($ch, curlopt_ssl_verifypeer, false); curl_setopt($ch, curlopt_postfields, json_encode($fields)); $result = curl_exec($ch); if ($result === false) { die('fcm send error: ' . curl_error($ch)); } curl_close($ch); var_dump($result); return $result; }
the output of
var_dump($result)
is
string(3) "to "
what should reponse working firebase server or how can understand firebase server working fine?
Comments
Post a Comment