Skip to content

Commit

Permalink
Include the validateOnly field only if it's value is true
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromegamez committed Aug 16, 2022
1 parent f479dc9 commit 54fc371
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Firebase/Messaging/Http/Request/SendMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,14 @@ final class SendMessage implements MessageRequest, RequestInterface
public function __construct(string $projectId, Message $message, bool $validateOnly = false)
{
$uri = Utils::uriFor('https://fcm.googleapis.com/v1/projects/'.$projectId.'/messages:send');
$body = Utils::streamFor(Json::encode(['message' => $message, 'validate_only' => $validateOnly]));

$payload = ['message' => $message];

if ($validateOnly === true) {
$payload['validate_only'] = true;
}

$body = Utils::streamFor(Json::encode($payload));
$headers = [
'Content-Type' => 'application/json; charset=UTF-8',
'Content-Length' => (string) $body->getSize(),
Expand Down

0 comments on commit 54fc371

Please sign in to comment.