I have implemented Push-Notifications into my Project and everything works fine so far. I\'ve tried sending Notifications through Pusher and this worked out just fine. But I
$title,
'text' => $body,
'sound' => 'default',
'badge' => 1,
'category' => $activitytype,
'content-available' => 1
);
$arrayToSend = array(
'to' => $token,
'notification' => $notification,
'priority' => 'high'
);
$json = json_encode($arrayToSend);
$headers = array();
$headers[] = 'Content-Type: application/json';
$headers[] = 'Authorization: key=' . $serverKey;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
//Send the request
echo $response = curl_exec($ch);
//Close request
if ($response === FALSE) {
die('FCM Send Error: ' . curl_error($ch));
}
curl_close($ch);
mysql_query("INSERT INTO `tbl_notifications`(`n_activity_name`,`n_user_id`,`n_device_id`, `n_notification`) VALUES ('$activitytype','$StudentAdmissionId','$id','$response')");
// #Echo Result Of FireBase Server
return $response;
}
?>
Use this for php & mysql backend for pusihing notification on android and ios on the same time
Here token of apns server is stored in db and pass to send fcm