diff --git a/common/framework/drivers/push/fcm.php b/common/framework/drivers/push/fcm.php index 6e20a6598..938c18358 100644 --- a/common/framework/drivers/push/fcm.php +++ b/common/framework/drivers/push/fcm.php @@ -59,37 +59,9 @@ class FCM extends Base implements \Rhymix\Framework\Drivers\PushInterface ); // Set notification - $notification = []; + $notification = $message->getNotifications() ?? []; $notification['title'] = $message->getSubject(); $notification['body'] = $message->getContent(); - if($message->getClickAction()) - { - $notification['click_action'] = $message->getClickAction(); - } - if($message->getSound()) - { - $notification['sound'] = $message->getSound(); - } - if($message->getBadge()) - { - $notification['badge'] = $message->getBadge(); - } - if($message->getIcon()) - { - $notification['icon'] = $message->getIcon(); - } - if($message->getTag()) - { - $notification['tag'] = $message->getTag(); - } - if($message->getColor()) - { - $notification['color'] = $message->getColor(); - } - if($message->getAndroidChannelId()) - { - $notification['android_channel_id'] = $message->getAndroidChannelId(); - } $chunked_token = array_chunk($tokens, 1000); foreach($chunked_token as $token_unit) diff --git a/common/framework/push.php b/common/framework/push.php index 48b407263..12268f820 100644 --- a/common/framework/push.php +++ b/common/framework/push.php @@ -14,13 +14,7 @@ class Push protected $to = array(); protected $subject = ''; protected $content = ''; - protected $click_action = ''; - protected $sound = ''; - protected $badge = ''; - protected $icon = ''; - protected $tag = ''; - protected $color = ''; - protected $android_channel_id = ''; + protected $notification = []; protected $data = []; protected $errors = array(); protected $success_tokens = array(); @@ -211,20 +205,10 @@ class Push */ public function setClickAction(string $click_action): bool { - $this->click_action = utf8_trim(utf8_clean($click_action)); + $this->notification['click_action'] = utf8_trim(utf8_clean($click_action)); return true; } - /** - * Get the click-action associated with this push notification. - * - * @return string - */ - public function getClickAction(): string - { - return $this->click_action; - } - /** * Set a sound to associate with this push notification. * @@ -233,20 +217,10 @@ class Push */ public function setSound(string $sound): bool { - $this->sound = utf8_trim(utf8_clean($sound)); + $this->notification['sound'] = utf8_trim(utf8_clean($sound)); return true; } - /** - * Get the sound associated with this push notification. - * - * @return string - */ - public function getSound(): string - { - return $this->sound; - } - /** * Set a badge to associate with this push notification. * @@ -255,19 +229,9 @@ class Push */ public function setBadge(string $badge): bool { - $this->badge = utf8_trim(utf8_clean($badge)); + $this->notification['badge'] = utf8_trim(utf8_clean($badge)); return true; } - - /** - * Get the badge associated with this push notification. - * - * @return string - */ - public function getBadge(): string - { - return $this->badge; - } /** * Set an icon to associate with this push notification. @@ -277,19 +241,9 @@ class Push */ public function setIcon(string $icon): bool { - $this->icon = utf8_trim(utf8_clean($icon)); + $this->notification['icon'] = utf8_trim(utf8_clean($icon)); return true; } - - /** - * Get the icon associated with this push notification. - * - * @return string - */ - public function getIcon(): string - { - return $this->icon; - } /** * Set a tag to associate with this push notification. @@ -299,20 +253,10 @@ class Push */ public function setTag(string $tag): bool { - $this->tag = utf8_trim(utf8_clean($tag)); + $this->notification['tag'] = utf8_trim(utf8_clean($tag)); return true; } - /** - * Get the tag associated with this push notification. - * - * @return string - */ - public function getTag(): string - { - return $this->tag; - } - /** * Set a color to associate with this push notification. * @@ -321,20 +265,10 @@ class Push */ public function setColor(string $color): bool { - $this->color = utf8_trim(utf8_clean($color)); + $this->notification['color'] = utf8_trim(utf8_clean($color)); return true; } - /** - * Get the color associated with this push notification. - * - * @return string - */ - public function getColor(): string - { - return $this->color; - } - /** * Set an android-channel-id to associate with this push notification. * @@ -343,18 +277,18 @@ class Push */ public function setAndroidChannelId(string $android_channel_id): bool { - $this->android_channel_id = utf8_trim(utf8_clean($android_channel_id)); + $this->notification['android_channel_id'] = utf8_trim(utf8_clean($android_channel_id)); return true; } /** - * Get the android-channel-id associated with this push notification. + * Get notification array * - * @return string + * @return array */ - public function getAndroidChannelId(): string + public function getNotifications(): array { - return $this->android_channel_id; + return $this->notification; } /**