Skip to content

Commit 5f49733

Browse files
Raresmldvnfabpot
authored andcommitted
[Notifier] [Firebase] Add data field to options
1 parent 23836aa commit 5f49733

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ CHANGELOG
55
---
66

77
* The bridge is not marked as `@experimental` anymore
8+
* Add `data` field to options
89

910
5.1.0
1011
-----

FirebaseOptions.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,21 @@ abstract class FirebaseOptions implements MessageOptionsInterface
2727
*/
2828
protected $options;
2929

30-
public function __construct(string $to, array $options)
30+
private $data;
31+
32+
public function __construct(string $to, array $options, array $data = [])
3133
{
3234
$this->to = $to;
3335
$this->options = $options;
36+
$this->data = $data;
3437
}
3538

3639
public function toArray(): array
3740
{
3841
return [
3942
'to' => $this->to,
4043
'notification' => $this->options,
44+
'data' => $this->data,
4145
];
4246
}
4347

@@ -59,4 +63,11 @@ public function body(string $body): self
5963

6064
return $this;
6165
}
66+
67+
public function data(array $data): self
68+
{
69+
$this->data = $data;
70+
71+
return $this;
72+
}
6273
}

FirebaseTransport.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ protected function doSend(MessageInterface $message): SentMessage
6565
}
6666
$options['notification'] = $options['notification'] ?? [];
6767
$options['notification']['body'] = $message->getSubject();
68+
69+
$options['data'] = $options['data'] ?? [];
70+
6871
$response = $this->client->request('POST', $endpoint, [
6972
'headers' => [
7073
'Authorization' => sprintf('key=%s', $this->token),

0 commit comments

Comments
 (0)