Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
firebase_php
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
firebase_php
Commits
547d72ab
Commit
547d72ab
authored
1 year ago
by
Patrick Kenny
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3450693
by ptmkenny: Add validateToken() method
parent
d3fb2348
No related branches found
No related tags found
1 merge request
!33
Pn registration tokens integration
Pipeline
#187217
passed
1 year ago
Stage: build
Stage: validate
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/FirebasePhpMessagingApiInterface.php
+11
-0
11 additions, 0 deletions
src/FirebasePhpMessagingApiInterface.php
src/Service/FirebasePhpMessagingApi.php
+18
-0
18 additions, 0 deletions
src/Service/FirebasePhpMessagingApi.php
with
29 additions
and
0 deletions
src/FirebasePhpMessagingApiInterface.php
+
11
−
0
View file @
547d72ab
...
@@ -119,4 +119,15 @@ interface FirebasePhpMessagingApiInterface {
...
@@ -119,4 +119,15 @@ interface FirebasePhpMessagingApiInterface {
?int
$badge_count
=
NULL
,
?int
$badge_count
=
NULL
,
):
MulticastSendReport
;
):
MulticastSendReport
;
/**
* Validates a registration token with Google's servers.
*
* @param string $token
* The registration token to validate.
*
* @return bool
* TRUE if the token is valid. FALSE if not.
*/
public
function
validateToken
(
string
$token
):
bool
;
}
}
This diff is collapsed.
Click to expand it.
src/Service/FirebasePhpMessagingApi.php
+
18
−
0
View file @
547d72ab
...
@@ -213,4 +213,22 @@ class FirebasePhpMessagingApi extends FirebasePhpMessagingService implements Fir
...
@@ -213,4 +213,22 @@ class FirebasePhpMessagingApi extends FirebasePhpMessagingService implements Fir
}
}
}
}
/**
* {@inheritdoc}
*/
public
function
validateToken
(
string
$token
):
bool
{
if
(
trim
(
$token
)
===
''
)
{
throw
new
FirebasePhpInvalidArgumentException
(
'Token cannot be an empty string!'
);
}
/** @var non-empty-string $token */
$messaging_service
=
$this
->
getMessaging
();
$output
=
$messaging_service
->
validateRegistrationTokens
(
$token
);
// We are only validating one token, so if there is a single invalid result,
// the token is invalid.
if
(
isset
(
$output
[
'invalid'
][
0
]))
{
return
FALSE
;
}
return
TRUE
;
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment