Skip to content

Commit

Permalink
Merge pull request #64 from HarmJan1990/master
Browse files Browse the repository at this point in the history
Adding withAuthenticationKey to use multiple Firebase Authorization Keys
  • Loading branch information
gentritabazi authored May 10, 2023
2 parents ee8ba8d + c3100c7 commit c25c1e9
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/Services/Larafirebase.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class Larafirebase

private $fromArray;

private $authenticationKey;

private $fromRaw;

const API_URI = 'https://fcm.googleapis.com/fcm/send';
Expand Down Expand Up @@ -88,6 +90,13 @@ public function withAdditionalData($additionalData)
return $this;
}

public function withAuthenticationKey($authenticationKey)
{
$this->authenticationKey = $authenticationKey;

return $this;
}

public function fromArray($fromArray)
{
$this->fromArray = $fromArray;
Expand Down Expand Up @@ -145,8 +154,10 @@ public function send()

private function callApi($fields): Response
{
$authenticationKey = isset($this->authenticationKey) ? $this->authenticationKey:config('larafirebase.authentication_key');

$response = Http::withHeaders([
'Authorization' => 'key=' . config('larafirebase.authentication_key')
'Authorization' => 'key=' . $authenticationKey
])->post(self::API_URI, $fields);

return $response;
Expand Down

0 comments on commit c25c1e9

Please sign in to comment.