-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathMessage.php
More file actions
104 lines (87 loc) · 1.92 KB
/
Message.php
File metadata and controls
104 lines (87 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<?php
/**
* WebPush Message
*/
namespace Surge\Services\Web;
use Surge\Components\Interfaces;
class Message implements Interfaces\MessageInterface
{
public $bigPicture;
public $badge;
public $group;
public $largeIcon;
public $title;
public $message;
public $token;
public $service = "Web";
public $uri;
public $json = "";
public function setBadge($badge)
{
$this->badge = $badge;
return $this;
}
public function setGroup($group)
{
$this->group = $group;
return $this;
}
public function setBigPicture($bigPicture)
{
$this->bigPicture = $bigPicture;
return $this;
}
public function setLargeIcon($icon)
{
$this->largeIcon = $icon;
return $this;
}
public function getToken()
{
return json_decode(base64_decode($this->token), true);
}
public function setToken($token)
{
$this->token = $token;
return $this;
}
public function setTitle($title)
{
$this->title = $title;
return $this;
}
public function setMessage($message)
{
$this->message = $message;
return $this;
}
public function setURI($uri)
{
$this->uri = $uri;
return $this;
}
public function setSound($sound)
{
return $this;
}
public function setJsonObject($json)
{
$this->json = $json;
return $this;
}
public function toJSON()
{
$payload = [
'notification' => [
'body' => $this->message,
'title' => $this->title ?: ' ',
'uri' => $this->uri,
'json' => $this->json,
'largeIcon' => $this->largeIcon,
'icon' => $this->bigPicture,
'badge' => intval($this->badge)
]
];
return json_encode($payload);
}
}