1 | <?php |
||
5 | class GcmMessage |
||
6 | { |
||
7 | /** |
||
8 | * Normal priority option. |
||
9 | * |
||
10 | * @var string |
||
11 | */ |
||
12 | const PRIORITY_NORMAL = 'normal'; |
||
13 | |||
14 | /** |
||
15 | * High priority option. |
||
16 | * |
||
17 | * @var string |
||
18 | */ |
||
19 | const PRIORITY_HIGH = 'high'; |
||
20 | |||
21 | /** |
||
22 | * Default sound option. |
||
23 | * |
||
24 | * @var string |
||
25 | */ |
||
26 | const DEFAULT_SOUND = 'default'; |
||
27 | |||
28 | /** |
||
29 | * The title of the notification. |
||
30 | * |
||
31 | * @var string |
||
32 | */ |
||
33 | public $title; |
||
34 | |||
35 | /** |
||
36 | * The message of the notification. |
||
37 | * |
||
38 | * @var string |
||
39 | */ |
||
40 | public $message; |
||
41 | |||
42 | /** |
||
43 | * The priority of the notification. |
||
44 | * |
||
45 | * @var string |
||
46 | */ |
||
47 | public $priority = self::PRIORITY_NORMAL; |
||
48 | |||
49 | /** |
||
50 | * Notification sound. |
||
51 | * |
||
52 | * @var string |
||
53 | */ |
||
54 | public $sound = self::DEFAULT_SOUND; |
||
55 | |||
56 | /** |
||
57 | * Additional data of the notification. |
||
58 | * |
||
59 | * @var array |
||
60 | */ |
||
61 | public $data = []; |
||
62 | |||
63 | /** |
||
64 | * Additional notification data of the notification. |
||
65 | * |
||
66 | * @var array |
||
67 | */ |
||
68 | public $notification = []; |
||
69 | |||
70 | /** |
||
71 | * Create a new message instance. |
||
72 | * |
||
73 | * @param string|null $title |
||
74 | * @param string|null $message |
||
75 | * @param array $data |
||
76 | * @param string $priority |
||
77 | * @return static |
||
78 | */ |
||
79 | 1 | public static function create($title = null, $message = null, $data = [], $priority = self::PRIORITY_NORMAL, $sound = self::DEFAULT_SOUND, $notification = []) |
|
83 | |||
84 | /** |
||
85 | * Create a new message instance. |
||
86 | * |
||
87 | * @param string|null $title |
||
88 | * @param string|null $message |
||
89 | * @param array $data |
||
90 | * @param string $priority |
||
91 | * @param string $sound |
||
92 | */ |
||
93 | 11 | public function __construct($title = null, $message = null, $data = [], $priority = self::PRIORITY_NORMAL, $sound = self::DEFAULT_SOUND, $notification = []) |
|
102 | |||
103 | /** |
||
104 | * Set the title of the notification. |
||
105 | * |
||
106 | * @param string $title |
||
107 | * @return $this |
||
108 | */ |
||
109 | 1 | public function title($title) |
|
115 | |||
116 | /** |
||
117 | * Set the message of the notification. |
||
118 | * |
||
119 | * @param string $message |
||
120 | * @return $this |
||
121 | */ |
||
122 | 1 | public function message($message) |
|
128 | |||
129 | /** |
||
130 | * Set the priority of the notification. |
||
131 | * |
||
132 | * @param string $priority |
||
133 | * @return $this |
||
134 | */ |
||
135 | 1 | public function priority($priority) |
|
141 | |||
142 | /** |
||
143 | * Set the sound for notification. |
||
144 | * |
||
145 | * @param string $sound |
||
146 | * @return $this |
||
147 | */ |
||
148 | 1 | public function sound($sound) |
|
154 | |||
155 | /** |
||
156 | * Add data to the notification. |
||
157 | * |
||
158 | * @param string $key |
||
159 | * @param mixed $value |
||
160 | * @return $this |
||
161 | */ |
||
162 | 1 | 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 notification data to the notification. |
||
184 | * |
||
185 | * @param string $key |
||
186 | * @param mixed $value |
||
187 | * @return $this |
||
188 | */ |
||
189 | 1 | public function notification($key, $value) |
|
195 | |||
196 | /** |
||
197 | * Override the notification data of the notification. |
||
198 | * |
||
199 | * @param array $notification |
||
200 | * @return $this |
||
201 | */ |
||
202 | public function setNotification($notification) |
||
208 | |||
209 | /** |
||
210 | * Add an action to the notification. |
||
211 | * |
||
212 | * @param string $action |
||
213 | * @param mixed $params |
||
214 | * @return $this |
||
215 | */ |
||
216 | public function action($action, $params = null) |
||
223 | } |
||
224 |