sendSimpleNotification(string $serverKey, string $to, array $data) function addet to device NotificationManager
This commit is contained in:
parent
32c5d7feda
commit
65af811e3e
@ -18,7 +18,26 @@ class NotificationManager
|
|||||||
function getSubscription(){
|
function getSubscription(){
|
||||||
return Db::loadAll('SELECT * FROM notifications;', array());
|
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
|
class Notification
|
||||||
{
|
{
|
||||||
public $server_key = '';
|
public $server_key = '';
|
||||||
|
Loading…
Reference in New Issue
Block a user