Skip to content

Commit cc3e61d

Browse files
authored
Merge pull request #108 from dunice/master
Added attributes to PushMessage class and adjustmented PushChannel
2 parents 9ab69b7 + f68e218 commit cc3e61d

File tree

3 files changed

+36
-5
lines changed

3 files changed

+36
-5
lines changed

src/Channels/GcmChannel.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ protected function buildData(PushMessage $message)
2626
'title' => $message->title,
2727
'body' => $message->body,
2828
'sound' => $message->sound,
29+
'color' => $message->color,
2930
'click_action' => $message->click_action,
3031
],
3132
];

src/Channels/PushChannel.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ public function __construct(PushNotification $push)
3232
*/
3333
public function send($notifiable, Notification $notification)
3434
{
35-
if (! $to = $notifiable->routeNotificationFor($this->notificationFor())) {
36-
return;
37-
}
38-
3935
$message = $this->buildMessage($notifiable, $notification);
40-
4136
$data = $this->buildData($message);
37+
$to = $message->to ?? $notifiable->routeNotificationFor($this->notificationFor());
38+
39+
if (! $to) {
40+
return;
41+
}
4242

4343
$this->push($this->pushServiceName(), $to, $data, $message);
4444
}

src/Messages/PushMessage.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44

55
class PushMessage
66
{
7+
/**
8+
* @var string
9+
*/
10+
public $to;
11+
712
/**
813
* @var string
914
*/
@@ -49,6 +54,11 @@ class PushMessage
4954
*/
5055
public $config = [];
5156

57+
/**
58+
* @var string
59+
*/
60+
public $color = '#000000';
61+
5262
/**
5363
* Create a new message instance.
5464
*
@@ -60,6 +70,13 @@ public function __construct($body = '')
6070
$this->body = $body;
6171
}
6272

73+
public function to($to)
74+
{
75+
$this->to = $to;
76+
77+
return $this;
78+
}
79+
6380
/**
6481
* Set the message body.
6582
*
@@ -151,6 +168,19 @@ public function badge($badge)
151168
return $this;
152169
}
153170

171+
/**
172+
* Set notification icon color.
173+
*
174+
* @param string $color
175+
* @return $this
176+
*/
177+
public function color($color)
178+
{
179+
$this->color = $color;
180+
181+
return $this;
182+
}
183+
154184
/**
155185
* Set message extra data.
156186
*

0 commit comments

Comments
 (0)