public static function sendToAllDevices($userId, $message, $prod) { $deviceTokens = User::getUsersDeviceTokensAsArray($userId); $allDelivered = array(); if (isset($deviceTokens) && is_array($deviceTokens) && count($deviceTokens > 0)) { foreach ($deviceTokens as $deviceToken) { // save all the results of whether a message was delivered $delivered = PushNotification::send($deviceToken, $message, $prod); array_push($allDelivered, $delivered); } // return whether or not pushes to all devices are successful return count(array_keys($allDelivered, true)) === count($allDelivered); } //otherwise, there are no records for that user so return false //because no messages were sent return false; }