diff --git a/Entity/DeviceNotification.php b/Entity/DeviceNotification.php index 567c6ea..97776a2 100644 --- a/Entity/DeviceNotification.php +++ b/Entity/DeviceNotification.php @@ -38,6 +38,10 @@ public function setDeviceToken($token) */ public function addDeviceToken($token) { + if(is_string($token) === false){ + throw new \InvalidArgumentException('Token must be a string!'); + } + $this->deviceTokens->add($token); return $this; @@ -48,6 +52,10 @@ public function addDeviceToken($token) */ public function setDeviceTokens($tokens) { + if(is_array($tokens) === false){ + throw new \InvalidArgumentException('Tokens must be an array of strings!'); + } + $this->deviceTokens = new ArrayCollection($tokens); return $this; diff --git a/FCMClient.php b/FCMClient.php index 3fae27a..54e30d8 100644 --- a/FCMClient.php +++ b/FCMClient.php @@ -48,7 +48,7 @@ public function __construct(Client $client) * @param null | array $token * @return DeviceNotification */ - public function createDeviceNotification($title = null, $body = null, $token = null) + public function createDeviceNotification($title = null, $body = null, $token = array()) { $notification = new DeviceNotification(); $notification