@@ 290-312 (lines=23) @@ | ||
287 | * |
|
288 | * @return array |
|
289 | */ |
|
290 | public function toiOS() |
|
291 | { |
|
292 | $message = [ |
|
293 | 'apns' => [ |
|
294 | 'aps' => [ |
|
295 | 'alert' => [ |
|
296 | 'title' => $this->title, |
|
297 | 'body' => $this->body, |
|
298 | ], |
|
299 | 'sound' => $this->sound, |
|
300 | 'badge' => $this->badge, |
|
301 | ], |
|
302 | ], |
|
303 | ]; |
|
304 | ||
305 | if (!empty($this->meta)) { |
|
306 | $message['apns']['data'] = $this->meta; |
|
307 | } |
|
308 | ||
309 | $this->formatMessage($message); |
|
310 | ||
311 | return $message; |
|
312 | } |
|
313 | ||
314 | /** |
|
315 | * Format the message for Android. |
|
@@ 319-339 (lines=21) @@ | ||
316 | * |
|
317 | * @return array |
|
318 | */ |
|
319 | public function toAndroid() |
|
320 | { |
|
321 | $message = [ |
|
322 | 'fcm' => [ |
|
323 | 'notification' => array_filter([ |
|
324 | 'title' => $this->title, |
|
325 | 'body' => $this->body, |
|
326 | 'sound' => $this->sound, |
|
327 | 'icon' => $this->icon, |
|
328 | ]), |
|
329 | ], |
|
330 | ]; |
|
331 | ||
332 | if (!empty($this->meta)) { |
|
333 | $message['fcm']['data'] = $this->meta; |
|
334 | } |
|
335 | ||
336 | $this->formatMessage($message); |
|
337 | ||
338 | return $message; |
|
339 | } |
|
340 | ||
341 | /** |
|
342 | * Return the current platform. |