Hi all im new to this topic, my goal is to receive notification from server side which is laravel, and i dont know how to do it, any suggestions or any advice or links? will be a great help thanks
I have implemented the same except my backend is codeigniter.
Anyways i used onesignal for push notification which is great so far for ionic i have found.
Here is the link for how to integrate that into app.
Now, to send notification from the backend. you can use this code.
$content = array(
"en" =>"TIHS IS NOTIFICATION DESCRIPTION"
);
$fields = array(
'app_id' => "YOUR ONESIGNAL APP ID",
'include_player_ids' => array("HERE WILL BE THE DEVICE TOKEN YOU RECEIVE FROM ONESIGNAL PLUGIN INITIALIZATION"),
'data' =>"ANY ADDITIONAL DATA YOU WANT SEND",
'contents' => $content,
'headings'=>array("en"=>"HERE COMES THE NOTIFICATION TITLE"),
'large_icon'=>"IMAGE URL FOR YOUR APP LOGO TO DISPLAY IT IN NOTIFICATION",
'big_picture'=>"IF YOU WANT TO SEND BIG IMAGE WITH NOTIFICATION, URL GOES HERE",
'android_sound'=>"notification"
);
$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 YOUR AUTHORIZATION KEY GOES HERE'));
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);