MChaos

sendPushTopic

Aug 15th, 2025
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.41 KB | None | 0 0
  1. public function sendPushTopic($data, $key = false, $topic, $id = false)
  2.     {
  3.         $message = CloudMessage::withTarget("topic", $topic)
  4.             ->withNotification(Notification::create($data['title'], $data['body']))
  5.             ->withApnsConfig(
  6.                 [
  7.                     'headers' => [
  8.                         'apns-priority' => '10'
  9.                     ],
  10.                     'payload' => [
  11.                         'aps' => [
  12.                             'alert' => [
  13.                                 'title' => $data['title'],
  14.                                 'body' => $data['body'],
  15.                             ],
  16.                             'badge' => 1,
  17.                         ],
  18.                     ],
  19.                 ]
  20.             )
  21.             ->withAndroidConfig([
  22.                 'ttl' => '3600s',
  23.                 'priority' => 'normal',
  24.                 'notification' => [
  25.                     'title' => $data['title'],
  26.                     'body' => $data['body'],
  27.                     'icon' => 'https://cabinet.evpoint.md/img/logo_b.png?width=40&height=40',
  28.                     'color' => '#6bba82',
  29.                     'sound' => 'bingbong.aiff'
  30.                 ],
  31.             ])
  32.             ->withData(['key' => $key, 'id' => $id]);
  33.  
  34.         try {
  35.             return $this->messaging->send($message);
  36.         } catch (Exception $e) {
  37.             return $e;
  38.         }
  39.     }
Advertisement
Add Comment
Please, Sign In to add comment