From 20a0fd8b7e4be85427981dfdb40f3aac27bf66b7 Mon Sep 17 00:00:00 2001 From: Christian Fuentes Date: Wed, 30 Oct 2019 09:38:56 +0100 Subject: [PATCH] Add isInvalidToken method --- src/Khrizt/PushNotiphications/Model/Apns/Response.php | 10 ++++++++++ src/Khrizt/PushNotiphications/Model/Fcm/Response.php | 10 ++++++++++ .../PushNotiphications/Model/ResponseInterface.php | 2 ++ 3 files changed, 22 insertions(+) diff --git a/src/Khrizt/PushNotiphications/Model/Apns/Response.php b/src/Khrizt/PushNotiphications/Model/Apns/Response.php index b096c33..a886737 100644 --- a/src/Khrizt/PushNotiphications/Model/Apns/Response.php +++ b/src/Khrizt/PushNotiphications/Model/Apns/Response.php @@ -205,6 +205,16 @@ public function isUnregisteredToken(): bool return $this->status === 410; } + /** + * Returns if notification was sent to an unregistered token. + * + * @return bool + */ + public function isInvalidToken(): bool + { + return $this->errorCode === "BadDeviceToken"; + } + /** * Gets the value of status. * diff --git a/src/Khrizt/PushNotiphications/Model/Fcm/Response.php b/src/Khrizt/PushNotiphications/Model/Fcm/Response.php index b2f017f..277a6e0 100644 --- a/src/Khrizt/PushNotiphications/Model/Fcm/Response.php +++ b/src/Khrizt/PushNotiphications/Model/Fcm/Response.php @@ -124,6 +124,16 @@ public function isUnregisteredToken(): bool return $this->errorCode === 'NotRegistered'; } + /** + * Returns if notification was sent to an unregistered token. + * + * @return bool + */ + public function isInvalidToken(): bool + { + return $this->errorCode === "InvalidRegistration"; + } + /** * Gets the value of errorCode. * diff --git a/src/Khrizt/PushNotiphications/Model/ResponseInterface.php b/src/Khrizt/PushNotiphications/Model/ResponseInterface.php index e80c400..f76b987 100644 --- a/src/Khrizt/PushNotiphications/Model/ResponseInterface.php +++ b/src/Khrizt/PushNotiphications/Model/ResponseInterface.php @@ -10,6 +10,8 @@ public function getToken(): string; public function isUnregisteredToken(): bool; + public function isInvalidToken(): bool; + public function isOk(): bool; public function getErrorCode(): ?string;