1 | <?php |
||
5 | class ApnMessage |
||
6 | { |
||
7 | /** |
||
8 | * The title of the notification. |
||
9 | * |
||
10 | * @var string |
||
11 | */ |
||
12 | public $title; |
||
13 | |||
14 | /** |
||
15 | * The body of the notification. |
||
16 | * |
||
17 | * @var string |
||
18 | */ |
||
19 | public $body; |
||
20 | |||
21 | /** |
||
22 | * The badge of the notification. |
||
23 | * |
||
24 | * @var int |
||
25 | */ |
||
26 | public $badge; |
||
27 | |||
28 | /** |
||
29 | * The sound for the notification. |
||
30 | * |
||
31 | * @var string|null |
||
32 | */ |
||
33 | public $sound; |
||
34 | |||
35 | /** |
||
36 | * The category for action button. |
||
37 | * |
||
38 | * @var string|null |
||
39 | * */ |
||
40 | public $category; |
||
41 | |||
42 | /** |
||
43 | * Value indicating incoming resource in the notification. |
||
44 | * |
||
45 | * @var int|null |
||
46 | */ |
||
47 | public $contentAvailable = null; |
||
48 | |||
49 | /** |
||
50 | * Additional data of the notification. |
||
51 | * |
||
52 | * @var array |
||
53 | */ |
||
54 | public $custom = []; |
||
55 | |||
56 | /** |
||
57 | * @param string|null $title |
||
58 | * @param string|null $body |
||
59 | * @param array $custom |
||
60 | * @param null|int $badge |
||
61 | * |
||
62 | * @return static |
||
63 | */ |
||
64 | 1 | public static function create($title = null, $body = null, $custom = [], $badge = null) |
|
65 | { |
||
66 | 1 | return new static($title, $body, $custom, $badge); |
|
67 | } |
||
68 | |||
69 | /** |
||
70 | * @param string|null $title |
||
71 | * @param string|null $body |
||
72 | * @param array $custom |
||
73 | * @param null|int $badge |
||
74 | * |
||
75 | * @return static |
||
|
|||
76 | */ |
||
77 | 13 | public function __construct($title = null, $body = null, $custom = [], $badge = null) |
|
84 | |||
85 | /** |
||
86 | * Set the alert title of the notification. |
||
87 | * |
||
88 | * @param string $title |
||
89 | * |
||
90 | * @return $this |
||
91 | */ |
||
92 | 1 | public function title($title) |
|
98 | |||
99 | /** |
||
100 | * Set the alert message of the notification. |
||
101 | * |
||
102 | * @param string $body |
||
103 | * |
||
104 | * @return $this |
||
105 | */ |
||
106 | 1 | public function body($body) |
|
112 | |||
113 | /** |
||
114 | * Set the badge of the notification. |
||
115 | * |
||
116 | * @param int $badge |
||
117 | * |
||
118 | * @return $this |
||
119 | */ |
||
120 | 1 | public function badge($badge) |
|
126 | |||
127 | /** |
||
128 | * Set the sound for the notification. |
||
129 | * |
||
130 | * @param string|null $sound |
||
131 | * |
||
132 | * @return $this |
||
133 | */ |
||
134 | 2 | public function sound($sound = 'default') |
|
140 | |||
141 | /** |
||
142 | * Set category for this notification. |
||
143 | * |
||
144 | * @param string|null $category |
||
145 | * |
||
146 | * @return $this |
||
147 | * */ |
||
148 | 1 | public function category($category) |
|
154 | |||
155 | /** |
||
156 | * Set content available value for this notification. |
||
157 | * |
||
158 | * @param int $value |
||
159 | * |
||
160 | * @return $this |
||
161 | */ |
||
162 | 1 | public function contentAvailable($value = 1) |
|
168 | |||
169 | /** |
||
170 | * Add custom data to the notification. |
||
171 | * |
||
172 | * @param string $key |
||
173 | * @param mixed $value |
||
174 | * |
||
175 | * @return $this |
||
176 | */ |
||
177 | 2 | public function custom($key, $value) |
|
183 | |||
184 | /** |
||
185 | * Override the data of the notification. |
||
186 | * |
||
187 | * @param array $custom |
||
188 | * |
||
189 | * @return $this |
||
190 | */ |
||
191 | 1 | public function setCustom($custom) |
|
197 | |||
198 | /** |
||
199 | * Add an action to the notification. |
||
200 | * |
||
201 | * @param string $action |
||
202 | * @param mixed $params |
||
203 | * |
||
204 | * @return $this |
||
205 | */ |
||
206 | 1 | public function action($action, $params = null) |
|
213 | } |
||
214 |
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.