PHP code example of mtgofa / fcm-laravel-notification
1. Go to this page and download the library: Download mtgofa/fcm-laravel-notification 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/ */
mtgofa / fcm-laravel-notification example snippets
namespace App\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use MTGofa\FCM\Messages\FirebaseMessage;
class MyNotification extends Notification
{
use Queueable;
public function via($notifiable)
{
return ['fcm'];
}
public function toFcm($notifiable)
{
return (new FirebaseMessage())->setContent('Test Notification', 'This is a Test');
}
}
use Illuminate\Database\Eloquent\Model;
use Illuminate\Notifications\Notifiable;
class User extends Model {
use Notifiable;
public function routeNotificationForFcm() {
//return a device token, either from the model or from some other place.
return $this->device_token;
}
}