Skip to content

Add support for validating multiple messages and registration tokens#520

Merged
jeromegamez merged 1 commit into5.xfrom
multi-validate
Dec 10, 2020
Merged

Add support for validating multiple messages and registration tokens#520
jeromegamez merged 1 commit into5.xfrom
multi-validate

Conversation

@jeromegamez
Copy link
Member

Addresses #511

With this, it will be possible to validate up to 500 messages and/or registration tokens for validity at once.

How to test

composer require "kreait/firebase-php: dev-multi-validate"

Validate registration tokens

$registrationTokens = [/* ... */];

$result = $messaging->validateRegistrationTokens($registrationTokens);

The result will be an array with the following format:

[
    'valid' => [/* valid tokens that are valid and registered to the current Firebase project */],
    'unknown => [/* valid tokens that are valid, but not registered to the current Firebase project */],
    'invalid' => [/* invalid/malformed tokens*/],
]

Validate multiple messages

Validating multiple messages has the same limitations as actually sending them (only 500 messages can be checked at a time - if you need to validate more, you need to chunk the items beforehand)

$validateOnly = true;

$messaging->send($message, $validateOnly);
$messaging->sendMulticast($message, $tokens, $validateOnly);
$messaging->sendAll($messages, $validateOnly);

:octocat:

@codecov
Copy link

codecov bot commented Dec 10, 2020

Codecov Report

Merging #520 (098efff) into 5.x (d637e80) will increase coverage by 0.13%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##                5.x     #520      +/-   ##
============================================
+ Coverage     92.60%   92.73%   +0.13%     
  Complexity     1543     1543              
============================================
  Files           152      151       -1     
  Lines          3744     3744              
============================================
+ Hits           3467     3472       +5     
+ Misses          277      272       -5     

@jeromegamez jeromegamez merged commit 20d1ee9 into 5.x Dec 10, 2020
@jeromegamez jeromegamez deleted the multi-validate branch December 10, 2020 10:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant