1 | <?php |
||
5 | class GcmMessage |
||
6 | { |
||
7 | const PRIORITY_NORMAL = 'normal'; |
||
8 | const PRIORITY_HIGH = 'high'; |
||
9 | |||
10 | /** |
||
11 | * The title of the notification. |
||
12 | * |
||
13 | * @var string |
||
14 | */ |
||
15 | public $title; |
||
16 | |||
17 | /** |
||
18 | * The message of the notification. |
||
19 | * |
||
20 | * @var string |
||
21 | */ |
||
22 | public $message; |
||
23 | |||
24 | /** |
||
25 | * The badge of the notification. |
||
26 | * @warning UNUSED |
||
27 | * |
||
28 | * @var int |
||
29 | */ |
||
30 | public $badge; |
||
31 | |||
32 | /** |
||
33 | * The priority of the notification. |
||
34 | * |
||
35 | * @var string |
||
36 | */ |
||
37 | public $priority = self::PRIORITY_NORMAL; |
||
38 | |||
39 | /** |
||
40 | * Additional data of the notification. |
||
41 | * |
||
42 | * @var array |
||
43 | */ |
||
44 | public $data = []; |
||
45 | |||
46 | /** |
||
47 | * @param string|null $title |
||
48 | * @param string|null $message |
||
49 | * @param array $data |
||
50 | * @param string $priority |
||
51 | * |
||
52 | * @return static |
||
53 | */ |
||
54 | 1 | public static function create($title = null, $message = null, $data = [], $priority = self::PRIORITY_NORMAL) |
|
58 | |||
59 | /** |
||
60 | * @param string|null $title |
||
61 | * @param string|null $message |
||
62 | * @param array $data |
||
63 | * @param string $priority |
||
64 | */ |
||
65 | 8 | public function __construct($title = null, $message = null, $data = [], $priority = self::PRIORITY_NORMAL) |
|
72 | |||
73 | /** |
||
74 | * Set the title of the notification. |
||
75 | * |
||
76 | * @param string $title |
||
77 | * |
||
78 | * @return $this |
||
79 | */ |
||
80 | 1 | public function title($title) |
|
86 | |||
87 | /** |
||
88 | * Set the message of the notification. |
||
89 | * |
||
90 | * @param string $message |
||
91 | * |
||
92 | * @return $this |
||
93 | */ |
||
94 | 1 | public function message($message) |
|
100 | |||
101 | /** |
||
102 | * Set the badge of the notification. |
||
103 | * |
||
104 | * @param int $badge |
||
105 | * |
||
106 | * @return $this |
||
107 | */ |
||
108 | public function badge($badge) |
||
114 | |||
115 | /** |
||
116 | * Set the priority of the notification. |
||
117 | * |
||
118 | * @param string $priority |
||
119 | * |
||
120 | * @return $this |
||
121 | */ |
||
122 | 1 | public function priority($priority) |
|
128 | |||
129 | /** |
||
130 | * Add data to the notification. |
||
131 | * |
||
132 | * @param string $key |
||
133 | * @param mixed $value |
||
134 | * |
||
135 | * @return $this |
||
136 | */ |
||
137 | 1 | public function data($key, $value) |
|
143 | |||
144 | /** |
||
145 | * Override the data of the notification. |
||
146 | * |
||
147 | * @param array $data |
||
148 | * @return $this |
||
149 | */ |
||
150 | public function setData($data) |
||
156 | |||
157 | /** |
||
158 | * Add an action to the notification. |
||
159 | * |
||
160 | * @param string $action |
||
161 | * @param mixed $params |
||
162 | * |
||
163 | * @return $this |
||
164 | */ |
||
165 | public function action($action, $params = null) |
||
172 | } |
||
173 |