Periodical sync from dev FTP

This commit is contained in:
JonatanRek
2020-01-16 14:33:11 +01:00
parent 6f0fa2f81e
commit ad89a18093
6 changed files with 43 additions and 24 deletions

View File

@@ -2,6 +2,7 @@
/**
* Notification Manager
*/
//TODO: Working timestamp to body or $title
class NotificationManager
{
function addSubscriber($userID = '', $token = ''){
@@ -19,7 +20,7 @@ class NotificationManager
return Db::loadAll('SELECT * FROM notifications;', array());
}
function sendSimpleNotification(string $serverKey, string $to, array $data){
function sendSimpleNotification(string $serverKey, string $to, array $data, bool $timeStamp = false){
$dataTemplate = [
'title' => '',
'body' => '',
@@ -30,6 +31,10 @@ class NotificationManager
return;
}
if ($timeStamp) {
$data['title'] = $data['title'] . date();
}
$notification = new Notification($serverKey);
$notification->to($to);
$notification->notification($data['title'], $data['body'], $data['icon'], '');
@@ -64,8 +69,12 @@ class Notification
$this->jsonPayload["to"] = $to;
}
function notification($title = '', $body = '', $icon = '', $action = '')
function notification($title = '', $body = '', $icon = '', $action = '', bool $timeStamp = false)
{
if ($timeStamp) {
$data['title'] = $data['title'] . date();
}
$this->jsonPayload["data"]["notification"]["title"] = $title;
$this->jsonPayload["data"]["notification"]["body"] = $body;
$this->jsonPayload["data"]["notification"]["icon"] = $icon;