1 | <?php |
||
5 | class GcmMessage |
||
6 | { |
||
7 | const PRIORITY_NORMAL = 'normal'; |
||
8 | const PRIORITY_HIGH = 'high'; |
||
9 | |||
10 | const DEFAULT_SOUND = 'default'; |
||
11 | |||
12 | /** |
||
13 | * The title of the notification. |
||
14 | * |
||
15 | * @var string |
||
16 | */ |
||
17 | public $title; |
||
18 | |||
19 | /** |
||
20 | * The message of the notification. |
||
21 | * |
||
22 | * @var string |
||
23 | */ |
||
24 | public $message; |
||
25 | |||
26 | /** |
||
27 | * The badge of the notification. |
||
28 | * @warning UNUSED |
||
29 | * |
||
30 | * @var int |
||
31 | */ |
||
32 | public $badge; |
||
33 | |||
34 | /** |
||
35 | * The priority of the notification. |
||
36 | * |
||
37 | * @var string |
||
38 | */ |
||
39 | public $priority = self::PRIORITY_NORMAL; |
||
40 | |||
41 | /** |
||
42 | * Notification sound. |
||
43 | * |
||
44 | * @var string |
||
45 | */ |
||
46 | public $sound = self::DEFAULT_SOUND; |
||
47 | |||
48 | /** |
||
49 | * Additional data of the notification. |
||
50 | * |
||
51 | * @var array |
||
52 | */ |
||
53 | public $data = []; |
||
54 | |||
55 | /** |
||
56 | * Additional notification data of the notification. |
||
57 | * |
||
58 | * @var array |
||
59 | */ |
||
60 | public $notification = []; |
||
61 | |||
62 | /** |
||
63 | * @param string|null $title |
||
64 | * @param string|null $message |
||
65 | * @param array $data |
||
66 | * @param string $priority |
||
67 | * |
||
68 | * @return static |
||
69 | */ |
||
70 | 1 | public static function create($title = null, $message = null, $data = [], $notification = [], $priority = self::PRIORITY_NORMAL, $sound = self::DEFAULT_SOUND) |
|
74 | |||
75 | /** |
||
76 | * @param string|null $title |
||
77 | * @param string|null $message |
||
78 | * @param array $data |
||
79 | * @param string $priority |
||
80 | * @param string $sound |
||
81 | */ |
||
82 | 11 | public function __construct($title = null, $message = null, $data = [], $notification = [], $priority = self::PRIORITY_NORMAL, $sound = self::DEFAULT_SOUND) |
|
91 | |||
92 | /** |
||
93 | * Set the title of the notification. |
||
94 | * |
||
95 | * @param string $title |
||
96 | * |
||
97 | * @return $this |
||
98 | */ |
||
99 | 1 | public function title($title) |
|
105 | |||
106 | /** |
||
107 | * Set the message of the notification. |
||
108 | * |
||
109 | * @param string $message |
||
110 | * |
||
111 | * @return $this |
||
112 | */ |
||
113 | 1 | public function message($message) |
|
119 | |||
120 | /** |
||
121 | * Set the badge of the notification. |
||
122 | * |
||
123 | * @param int $badge |
||
124 | * |
||
125 | * @return $this |
||
126 | */ |
||
127 | public function badge($badge) |
||
133 | |||
134 | /** |
||
135 | * Set the priority of the notification. |
||
136 | * |
||
137 | * @param string $priority |
||
138 | * |
||
139 | * @return $this |
||
140 | */ |
||
141 | 1 | public function priority($priority) |
|
147 | |||
148 | /** |
||
149 | * Set the sound for notification. |
||
150 | * |
||
151 | * @param string $sound |
||
152 | * |
||
153 | * @return $this |
||
154 | */ |
||
155 | 1 | public function sound($sound) |
|
161 | |||
162 | /** |
||
163 | * Add data to the notification. |
||
164 | * |
||
165 | * @param string $key |
||
166 | * @param mixed $value |
||
167 | * |
||
168 | * @return $this |
||
169 | */ |
||
170 | 1 | public function data($key, $value) |
|
176 | |||
177 | /** |
||
178 | * Override the data of the notification. |
||
179 | * |
||
180 | * @param array $data |
||
181 | * @return $this |
||
182 | */ |
||
183 | public function setData($data) |
||
189 | |||
190 | /** |
||
191 | * Add notification data to the notification. |
||
192 | * |
||
193 | * @param string $key |
||
194 | * @param mixed $value |
||
195 | * |
||
196 | * @return $this |
||
197 | */ |
||
198 | 1 | public function notification($key, $value) |
|
204 | |||
205 | /** |
||
206 | * Override the notification data of the notification. |
||
207 | * |
||
208 | * @param array $notification |
||
209 | * @return $this |
||
210 | */ |
||
211 | public function setNotification($notification) |
||
217 | |||
218 | /** |
||
219 | * Add an action to the notification. |
||
220 | * |
||
221 | * @param string $action |
||
222 | * @param mixed $params |
||
223 | * |
||
224 | * @return $this |
||
225 | */ |
||
226 | public function action($action, $params = null) |
||
233 | } |
||
234 |