Skip to content

Commit

Permalink
Merge pull request #31 from kutia-software-company/1.x
Browse files Browse the repository at this point in the history
Merge 1.x to Master
  • Loading branch information
gentritabazi committed Oct 31, 2021
2 parents 518b337 + d106785 commit c9b7fc3
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class MyController
return Larafirebase::withTitle('Test Title')
->withBody('Test body')
->withImage('https://firebase.google.com/images/social.png')
->withIcon('https://seeklogo.com/images/F/firebase-logo-402F407EE0-seeklogo.com.png')
->withClickAction('admin/notifications')
->withPriority('high')
->sendNotification($this->deviceTokens);
Expand Down
11 changes: 11 additions & 0 deletions src/Messages/FirebaseMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ class FirebaseMessage

private $image;

private $icon;

private $priority = self::PRIORITY_NORMAL;

private $fromArray;
Expand Down Expand Up @@ -48,6 +50,13 @@ public function withImage($image)
return $this;
}

public function withIcon($icon)
{
$this->icon = $icon;

return $this;
}

public function withPriority($priority)
{
$this->priority = $priority;
Expand All @@ -72,6 +81,7 @@ public function asNotification($deviceTokens)
->withBody($this->body)
->withClickAction($this->clickAction)
->withImage($this->image)
->withIcon($this->icon)
->withPriority($this->priority)
->sendNotification($deviceTokens);
}
Expand All @@ -86,6 +96,7 @@ public function asMessage($deviceTokens)
->withBody($this->body)
->withClickAction($this->clickAction)
->withImage($this->image)
->withIcon($this->icon)
->withPriority($this->priority)
->sendMessage($deviceTokens);
}
Expand Down
15 changes: 13 additions & 2 deletions src/Services/Larafirebase.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ class Larafirebase

private $image;

private $icon;

private $priority = self::PRIORITY_NORMAL;

private $fromArray;
Expand Down Expand Up @@ -53,6 +55,13 @@ public function withImage($image)
return $this;
}

public function withIcon($icon)
{
$this->icon = $icon;

return $this;
}

public function withPriority($priority)
{
$this->priority = $priority;
Expand Down Expand Up @@ -82,6 +91,7 @@ public function sendNotification($tokens)
'title' => $this->title,
'body' => $this->body,
'image' => $this->image,
'icon' => $this->icon,
'click_action' => $this->clickAction
],
'priority' => $this->priority
Expand All @@ -97,11 +107,12 @@ public function sendMessage($tokens)
'data' => ($this->fromArray) ? $this->fromArray : [
'title' => $this->title,
'body' => $this->body,
'image' => $this->image
'image' => $this->image,
'icon' => $this->icon
],
'priority' => $this->priority
);

return $this->callApi($fields);
}

Expand Down

0 comments on commit c9b7fc3

Please sign in to comment.