PHP code example of demian / laravel-notifications-gcm

1. Go to this page and download the library: Download demian/laravel-notifications-gcm library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

demian / laravel-notifications-gcm example snippets


use NotificationChannels\Gcm\GcmChannel;
use NotificationChannels\Gcm\GcmMessage;
use Illuminate\Notifications\Notification;

class AccountApproved extends Notification
{
    public function via($notifiable)
    {
        return [GcmChannel::class];
    }

    public function toGcm($notifiable)
    {
        return GcmMessage::create()
            ->badge(1)
            ->title('Account approved')
            ->message("Your {$notifiable->service} account was approved!");
    }
}

public function routeNotificationForGcm()
{
    return $this->gcm_token;
}