src/GcmChannel.php
public function send($notifiable, Notification $notification)
    {
        $tokens = (array) $notifiable->routeNotificationFor('gcm', $notification);
        if (empty($tokens)) {
            return;
        }

        $message = $notification->toGcm($notifiable);
        if (! $message) {
            return;
        }

        $packet = $this->getPacket($tokens, $message);

        try {
            $response = $this->client->send($packet);
        } catch (Exception $exception) {
            throw SendingFailed::create($exception);
        }

        if (! $response->getFailureCount() == 0) {
            $this->handleFailedNotifications($notifiable, $notification, $response);
        }
    }
public function send($notifiable, Notification $notification)
    {
        $tokens = (array) $notifiable->routeNotificationFor('gcm', $notification);
        if (empty($tokens)) {
            return;
        }

        $message = $notification->toGcm($notifiable);
        if (! $message) {
            return;
        }

        $packet = $this->getPacket($tokens, $message);

        try {
            $response = $this->client->send($packet);
        } catch (Exception $exception) {
            throw SendingFailed::create($exception);
        }

        if (! $response->getFailureCount() == 0) {
            $this->handleFailedNotifications($notifiable, $notification, $response);
        }
    }
public function send ( $ notifiable , Notification $ notification ) { $ tokens = ( array ) $ notifiable -> routeNotificationFor ( 'gcm' , $ notification ) ; if ( empty ( $ tokens ) ) { return ; } $ message = $ notification -> toGcm ( $ notifiable ) ; if ( ! $ message ) { return ; } $ packet = $ this -> getPacket ( $ tokens , $ message ) ; try { $ response = $ this -> client -> send ( $ packet ) ; } catch ( Exception $ exception ) { throw SendingFailed :: create ( $ exception ) ; } if ( ! $ response -> getFailureCount ( ) == 0 ) { $ this -> handleFailedNotifications ( $ notifiable , $ notification , $ response ) ; } }
Send the notification to Google Cloud Messaging.

@param mixed $notifiable
@param Notification $notification
@return void
@throws Exceptions\SendingFailed
Send the notification to Google Cloud Messaging .