This repository was archived by the owner on Jun 28, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +44
-1
lines changed Expand file tree Collapse file tree 5 files changed +44
-1
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,13 @@ class PayloadNotification implements Arrayable
2323 */
2424 protected $ body ;
2525
26+ /**
27+ * @internal
28+ *
29+ * @var null/string
30+ */
31+ protected $ channelId ;
32+
2633 /**
2734 * @internal
2835 *
@@ -102,6 +109,7 @@ public function __construct(PayloadNotificationBuilder $builder)
102109 {
103110 $ this ->title = $ builder ->getTitle ();
104111 $ this ->body = $ builder ->getBody ();
112+ $ this ->channelId = $ builder ->getChannelId ();
105113 $ this ->icon = $ builder ->getIcon ();
106114 $ this ->sound = $ builder ->getSound ();
107115 $ this ->badge = $ builder ->getBadge ();
@@ -124,6 +132,7 @@ public function toArray()
124132 $ notification = [
125133 'title ' => $ this ->title ,
126134 'body ' => $ this ->body ,
135+ 'android_channel_id ' => $ this ->channelId ,
127136 'icon ' => $ this ->icon ,
128137 'sound ' => $ this ->sound ,
129138 'badge ' => $ this ->badge ,
Original file line number Diff line number Diff line change @@ -39,6 +39,13 @@ class PayloadNotificationBuilder
3939 */
4040 protected $ sound ;
4141
42+ /**
43+ * @internal
44+ *
45+ * @var null|string
46+ */
47+ protected $ channelId ;
48+
4249 /**
4350 * @internal
4451 *
@@ -134,6 +141,20 @@ public function setBody($body)
134141 return $ this ;
135142 }
136143
144+ /**
145+ * Set a channel ID for android API >= 26.
146+ *
147+ * @param string $channelId
148+ *
149+ * @return PayloadNotificationBuilder current instance of the builder
150+ */
151+ public function setChannelId ($ channelId )
152+ {
153+ $ this ->channelId = $ channelId ;
154+
155+ return $ this ;
156+ }
157+
137158 /**
138159 * Supported Android
139160 * Indicates notification icon. example : Sets value to myicon for drawable resource myicon.
@@ -304,6 +325,16 @@ public function getBody()
304325 return $ this ->body ;
305326 }
306327
328+ /**
329+ * Get channel id for android api >= 26
330+ *
331+ * @return null|string
332+ */
333+ public function getChannelId ()
334+ {
335+ return $ this ->channelId ;
336+ }
337+
307338 /**
308339 * Get Icon.
309340 *
Original file line number Diff line number Diff line change @@ -90,6 +90,7 @@ public function it_construct_a_valid_json_with_notification()
9090 $ targetFull = '{
9191 "title":"test_title",
9292 "body":"test_body",
93+ "android_channel_id":"test_channel_id",
9394 "badge":"test_badge",
9495 "sound":"test_sound",
9596 "tag":"test_tag",
@@ -112,7 +113,9 @@ public function it_construct_a_valid_json_with_notification()
112113 $ json = json_encode ($ notificationBuilder ->build ()->toArray ());
113114 $ this ->assertJsonStringEqualsJsonString ($ targetPartial , $ json );
114115
115- $ notificationBuilder ->setTag ('test_tag ' )
116+ $ notificationBuilder
117+ ->setChannelId ('test_channel_id ' )
118+ ->setTag ('test_tag ' )
116119 ->setColor ('test_color ' )
117120 ->setClickAction ('test_click_action ' )
118121 ->setBodyLocationKey ('test_body_key ' )
You can’t perform that action at this time.
0 commit comments