Skip to content

Commit

Permalink
Merge pull request #108 from dunice/master
Browse files Browse the repository at this point in the history
Added attributes to PushMessage class and adjustmented PushChannel
  • Loading branch information
Edujugon authored Jan 25, 2020
2 parents 9ab69b7 + f68e218 commit cc3e61d
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/Channels/GcmChannel.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ protected function buildData(PushMessage $message)
'title' => $message->title,
'body' => $message->body,
'sound' => $message->sound,
'color' => $message->color,
'click_action' => $message->click_action,
],
];
Expand Down
10 changes: 5 additions & 5 deletions src/Channels/PushChannel.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ public function __construct(PushNotification $push)
*/
public function send($notifiable, Notification $notification)
{
if (! $to = $notifiable->routeNotificationFor($this->notificationFor())) {
return;
}

$message = $this->buildMessage($notifiable, $notification);

$data = $this->buildData($message);
$to = $message->to ?? $notifiable->routeNotificationFor($this->notificationFor());

if (! $to) {
return;
}

$this->push($this->pushServiceName(), $to, $data, $message);
}
Expand Down
30 changes: 30 additions & 0 deletions src/Messages/PushMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

class PushMessage
{
/**
* @var string
*/
public $to;

/**
* @var string
*/
Expand Down Expand Up @@ -49,6 +54,11 @@ class PushMessage
*/
public $config = [];

/**
* @var string
*/
public $color = '#000000';

/**
* Create a new message instance.
*
Expand All @@ -60,6 +70,13 @@ public function __construct($body = '')
$this->body = $body;
}

public function to($to)
{
$this->to = $to;

return $this;
}

/**
* Set the message body.
*
Expand Down Expand Up @@ -151,6 +168,19 @@ public function badge($badge)
return $this;
}

/**
* Set notification icon color.
*
* @param string $color
* @return $this
*/
public function color($color)
{
$this->color = $color;

return $this;
}

/**
* Set message extra data.
*
Expand Down

0 comments on commit cc3e61d

Please sign in to comment.