mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-10 20:44:28 +09:00
Add support for message.notification.image in FCM v1 push
This commit is contained in:
parent
296f37f5f5
commit
1bdb414291
2 changed files with 29 additions and 0 deletions
|
|
@ -16,6 +16,7 @@ class Push
|
||||||
protected $topics = [];
|
protected $topics = [];
|
||||||
protected $subject = '';
|
protected $subject = '';
|
||||||
protected $content = '';
|
protected $content = '';
|
||||||
|
protected $image = '';
|
||||||
protected $metadata = [];
|
protected $metadata = [];
|
||||||
protected $data = [];
|
protected $data = [];
|
||||||
protected $errors = [];
|
protected $errors = [];
|
||||||
|
|
@ -221,6 +222,29 @@ class Push
|
||||||
return $this->content;
|
return $this->content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the image.
|
||||||
|
*
|
||||||
|
* @param string $url
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function setImage(string $url): bool
|
||||||
|
{
|
||||||
|
$url = preg_replace('!^\./!', URL::getCurrentDomainURL(\RX_BASEURL), $url);
|
||||||
|
$this->image = $url;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the image.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getImage(): string
|
||||||
|
{
|
||||||
|
return $this->image;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set an click-action to associate with this push notification.
|
* Set an click-action to associate with this push notification.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -91,6 +91,7 @@ class FCMv1 extends Base implements PushInterface
|
||||||
$payload = ['message' => []];
|
$payload = ['message' => []];
|
||||||
$title = $message->getSubject();
|
$title = $message->getSubject();
|
||||||
$body = $message->getContent();
|
$body = $message->getContent();
|
||||||
|
$image = $message->getImage();
|
||||||
if ($title !== '')
|
if ($title !== '')
|
||||||
{
|
{
|
||||||
$payload['message']['notification']['title'] = $title;
|
$payload['message']['notification']['title'] = $title;
|
||||||
|
|
@ -99,6 +100,10 @@ class FCMv1 extends Base implements PushInterface
|
||||||
{
|
{
|
||||||
$payload['message']['notification']['body'] = $body;
|
$payload['message']['notification']['body'] = $body;
|
||||||
}
|
}
|
||||||
|
if ($image !== '')
|
||||||
|
{
|
||||||
|
$payload['message']['notification']['image'] = $image;
|
||||||
|
}
|
||||||
|
|
||||||
$metadata = $message->getMetadata();
|
$metadata = $message->getMetadata();
|
||||||
if (count($metadata))
|
if (count($metadata))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue