sendSimpleNotification(string $serverKey, string $to, array $data) function addet to device NotificationManager

This commit is contained in:
JonatanRek 2019-10-09 10:57:43 +02:00
parent 32c5d7feda
commit 65af811e3e
1 changed files with 19 additions and 0 deletions

View File

@ -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 = '';