feature #40102 [Notifier] [Firebase] Add data field to options (Raresmldvn)
This PR was squashed before being merged into the 5.3-dev branch.
Discussion
----------
[Notifier] [Firebase] Add data field to options
| Q | A
| ------------- | ---
| Branch? | 5.x
| Bug fix? | no
| New feature? | yes
| Deprecations? | no
| Tickets | https://github.com/symfony/symfony/issues/40078
| License | MIT
| Doc PR | symfony/symfony-docs#... <!-- required for new features -->
The Firebase Notifier must comply to the specifications at https://firebase.google.com/docs/cloud-messaging/xmpp-server-ref.html#notification-payload-support .
The options are missing the `data` field which is a common field for all types of notifications: web, ios and android.
Commits
-------
fa8064bbd3
[Notifier] [Firebase] Add data field to options
This commit is contained in:
commit
f93b7381d8
@ -5,6 +5,7 @@ CHANGELOG
|
|||||||
---
|
---
|
||||||
|
|
||||||
* The bridge is not marked as `@experimental` anymore
|
* The bridge is not marked as `@experimental` anymore
|
||||||
|
* Add `data` field to options
|
||||||
|
|
||||||
5.1.0
|
5.1.0
|
||||||
-----
|
-----
|
||||||
|
@ -27,10 +27,13 @@ abstract class FirebaseOptions implements MessageOptionsInterface
|
|||||||
*/
|
*/
|
||||||
protected $options;
|
protected $options;
|
||||||
|
|
||||||
public function __construct(string $to, array $options)
|
private $data;
|
||||||
|
|
||||||
|
public function __construct(string $to, array $options, array $data = [])
|
||||||
{
|
{
|
||||||
$this->to = $to;
|
$this->to = $to;
|
||||||
$this->options = $options;
|
$this->options = $options;
|
||||||
|
$this->data = $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function toArray(): array
|
public function toArray(): array
|
||||||
@ -38,6 +41,7 @@ abstract class FirebaseOptions implements MessageOptionsInterface
|
|||||||
return [
|
return [
|
||||||
'to' => $this->to,
|
'to' => $this->to,
|
||||||
'notification' => $this->options,
|
'notification' => $this->options,
|
||||||
|
'data' => $this->data,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,4 +63,11 @@ abstract class FirebaseOptions implements MessageOptionsInterface
|
|||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function data(array $data): self
|
||||||
|
{
|
||||||
|
$this->data = $data;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,6 +65,9 @@ final class FirebaseTransport extends AbstractTransport
|
|||||||
}
|
}
|
||||||
$options['notification'] = $options['notification'] ?? [];
|
$options['notification'] = $options['notification'] ?? [];
|
||||||
$options['notification']['body'] = $message->getSubject();
|
$options['notification']['body'] = $message->getSubject();
|
||||||
|
|
||||||
|
$options['data'] = $options['data'] ?? [];
|
||||||
|
|
||||||
$response = $this->client->request('POST', $endpoint, [
|
$response = $this->client->request('POST', $endpoint, [
|
||||||
'headers' => [
|
'headers' => [
|
||||||
'Authorization' => sprintf('key=%s', $this->token),
|
'Authorization' => sprintf('key=%s', $this->token),
|
||||||
|
Reference in New Issue
Block a user