Commit e823856e authored by Richard Weinhold's avatar Richard Weinhold 🔨

adds non-silent notification payload to GCM/FCM Handlers

parent 8b977b5c
......@@ -28,12 +28,17 @@ class FCMHandler extends PushHandler {
* @return bool
*/
public function send($message, array $payload = [], array $devices) {
$message = trim(stripslashes($message));
// build payload
$payload = [
'priority' => 'high',
'data' => array_merge([
'message' => trim(stripslashes($message)),
'priority' => 'high',
'notification' => [
'title' => substr($message, 0, 64) . (strlen($message) > 64 ? '...' : ''),
'body' => $message,
],
'data' => array_merge([
'message' => $message,
], $payload),
];
......@@ -49,7 +54,7 @@ class FCMHandler extends PushHandler {
*/
public function sendRaw(array $payload, array $devices) {
if (count($devices <= 1)) {
if (count($devices) <= 1) {
$payload = array_merge([
'to' => current($devices),
], $payload);
......
......@@ -28,11 +28,16 @@ class GCMHandler extends PushHandler {
* @return bool
*/
public function send($message, array $payload = [], array $devices) {
$message = trim(stripslashes($message));
// build payload
$payload = [
'data' => array_merge([
'message' => trim(stripslashes($message)),
'notification' => [
'title' => substr($message, 0, 64) . (strlen($message) > 64 ? '...' : ''),
'body' => $message,
],
'data' => array_merge([
'message' => $message,
], $payload),
];
......@@ -48,9 +53,15 @@ class GCMHandler extends PushHandler {
*/
public function sendRaw(array $payload, array $devices) {
$payload = array_merge([
'registration_ids' => $devices,
], $payload);
if (count($devices) <= 1) {
$payload = array_merge([
'to' => current($devices),
], $payload);
} else {
$payload = array_merge([
'registration_ids' => $devices,
], $payload);
}
// init http-headers
$headers = [
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment