From 65af811e3e324fe1826153c705172064a8cede00 Mon Sep 17 00:00:00 2001 From: JonatanRek Date: Wed, 9 Oct 2019 10:57:43 +0200 Subject: [PATCH] sendSimpleNotification(string $serverKey, string $to, array $data) function addet to device NotificationManager --- app/class/NotificationManager.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/app/class/NotificationManager.php b/app/class/NotificationManager.php index 4aa94cc..13320cf 100644 --- a/app/class/NotificationManager.php +++ b/app/class/NotificationManager.php @@ -18,7 +18,26 @@ class NotificationManager function getSubscription(){ return Db::loadAll('SELECT * FROM notifications;', array()); } + + function sendSimpleNotification(string $serverKey, string $to, array $data){ + $dataTemplate = [ + 'title' => '', + 'body' => '', + 'icon' => '', + ]; + + if (array_diff_key ($dataTemplate , $data)){ + return; + } + + $notification = new Notification($serverKey); + $notification->to($to); + $notification->notification($data['title'], $data['body'], $data['icon'], ''); + $notification->send(); + $notification = null; + } } + class Notification { public $server_key = '';