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 | * @param string|null $title |
||
57 | * @param string|null $message |
||
58 | * @param array $data |
||
59 | * @param string $priority |
||
60 | * |
||
61 | * @return static |
||
62 | */ |
||
63 | public static function create($title = null, $message = null, $data = [], $priority = self::PRIORITY_NORMAL, $sound = self::DEFAULT_SOUND) |
||
67 | |||
68 | /** |
||
69 | * @param string|null $title |
||
70 | * @param string|null $message |
||
71 | * @param array $data |
||
72 | * @param string $priority |
||
73 | * @param string $sound |
||
74 | */ |
||
75 | public function __construct($title = null, $message = null, $data = [], $priority = self::PRIORITY_NORMAL, $sound = self::DEFAULT_SOUND) |
||
83 | |||
84 | /** |
||
85 | * Set the title of the notification. |
||
86 | * |
||
87 | * @param string $title |
||
88 | * |
||
89 | * @return $this |
||
90 | */ |
||
91 | public function title($title) |
||
97 | |||
98 | /** |
||
99 | * Set the message of the notification. |
||
100 | * |
||
101 | * @param string $message |
||
102 | * |
||
103 | * @return $this |
||
104 | */ |
||
105 | public function message($message) |
||
111 | |||
112 | /** |
||
113 | * Set the badge of the notification. |
||
114 | * |
||
115 | * @param int $badge |
||
116 | * |
||
117 | * @return $this |
||
118 | */ |
||
119 | public function badge($badge) |
||
125 | |||
126 | /** |
||
127 | * Set the priority of the notification. |
||
128 | * |
||
129 | * @param string $priority |
||
130 | * |
||
131 | * @return $this |
||
132 | */ |
||
133 | public function priority($priority) |
||
139 | |||
140 | /** |
||
141 | * Set the sound for notification |
||
142 | * |
||
143 | * @param string $sound |
||
144 | * |
||
145 | * @return $this |
||
146 | */ |
||
147 | public function sound($sound) |
||
153 | |||
154 | /** |
||
155 | * Add data to the notification. |
||
156 | * |
||
157 | * @param string $key |
||
158 | * @param mixed $value |
||
159 | * |
||
160 | * @return $this |
||
161 | */ |
||
162 | public function data($key, $value) |
||
168 | |||
169 | /** |
||
170 | * Override the data of the notification. |
||
171 | * |
||
172 | * @param array $data |
||
173 | * @return $this |
||
174 | */ |
||
175 | public function setData($data) |
||
181 | |||
182 | /** |
||
183 | * Add an action to the notification. |
||
184 | * |
||
185 | * @param string $action |
||
186 | * @param mixed $params |
||
187 | * |
||
188 | * @return $this |
||
189 | */ |
||
190 | public function action($action, $params = null) |
||
197 | } |
||
198 |