LaravelFCM\Message\PayloadNotification::toArray PHP Method

toArray() public method

convert PayloadNotification to array
public toArray ( ) : array
return array
    function toArray()
    {
        $notification = ['title' => $this->title, 'body' => $this->body, 'icon' => $this->icon, 'sound' => $this->sound, 'badge' => $this->badge, 'tag' => $this->tag, 'color' => $this->color, 'click_action' => $this->clickAction, 'body_loc_key' => $this->bodyLocationKey, 'body_loc_args' => $this->bodyLocationArgs, 'title_loc_key' => $this->titleLocationKey, 'title_loc_args' => $this->titleLocationArgs];
        // remove null values
        $notification = array_filter($notification);
        return $notification;
    }

Usage Example

Beispiel #1
0
 /**
  * get notification transformed
  *
  * @return array|null
  */
 protected function getNotification()
 {
     return $this->notification ? $this->notification->toArray() : null;
 }
PayloadNotification